package com.ruoyi.system.mq;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.ParserConfig;
import com.ruoyi.common.core.utils.StringUtils;

import com.ruoyi.system.domain.SysDict;
import com.ruoyi.system.domain.TPeopleType;
import com.ruoyi.system.domain.TestWholeData;
import com.ruoyi.system.domain.TestWholeDataRetest;
import com.ruoyi.system.domain.dto.CombinedTestData;
import com.ruoyi.system.domain.dto.MembersDataDTO;
import com.ruoyi.system.domain.dto.MembersDataEntityDTO;
import com.ruoyi.system.domain.dto.MonitorDataDTO;
import com.ruoyi.system.domain.dto.SysUserLoginDTO;
import com.ruoyi.system.domain.dto.TTestPointInfoDTO;
import com.ruoyi.system.domain.dto.TestBodyfatDTO;
import com.ruoyi.system.domain.dto.TestCorporeityDTO;
import com.ruoyi.system.domain.dto.TestCorporeityResultsRetestDTO;
import com.ruoyi.system.domain.dto.TestMemberDTO;
import com.ruoyi.system.domain.dto.TestPowerDTO;
import com.ruoyi.system.domain.dto.TestPowerHeartrateDTO;
import com.ruoyi.system.domain.dto.TestTurgoscopeDTO;
import com.ruoyi.system.mapper.SysDictMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.TPeopleTypeMapper;
import com.ruoyi.system.mapper.TUnionscreeningMapper;
import com.ruoyi.system.mapper.TestwholedataMapper;
import com.ruoyi.system.mapper.TestwholedataretestMapper;
import com.ruoyi.system.mapper.uploaddownload.UploadMapper;
import com.ruoyi.common.core.utils.Global;
import com.ruoyi.system.utils.NullStringDeserializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.StringJoiner;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;

import static com.ruoyi.system.utils.UploadDataChangeUtils.appendIfZero1;
import static com.ruoyi.system.utils.UploadDataChangeUtils.appendIfZeroSafe1;
import static com.ruoyi.system.utils.UploadDataChangeUtils.appendSgzgIfZero1;
import static com.ruoyi.system.utils.UploadDataChangeUtils.appendWithValue1;
import static com.ruoyi.system.utils.UploadDataChangeUtils.getheartRate;
import static com.ruoyi.system.utils.UploadDataChangeUtils.isAgeAboveThreshold;
import static com.ruoyi.system.utils.UploadDataChangeUtils.joinDoubles;
import static com.ruoyi.system.utils.UploadDataChangeUtils.toSafeFloat;
import static com.ruoyi.system.utils.UploadDataChangeUtils.truncateToMonthWithoutZeroPadFast;

@Component
public class KafkaAsyncTaskConsumer {


    @Autowired
    private UploadMapper uploadMapper;
    @Autowired
    private SysDictMapper dictMapper;
    @Autowired
    private TPeopleTypeMapper peopleTypeMapper;
    @Autowired
    private TestwholedataMapper testWholeDataMapper;
    @Autowired
    private TestwholedataretestMapper testWholeDataRetestMapper;
    @Autowired
    private SysUserMapper sysUserInfoMapper;
    @Autowired
    private TUnionscreeningMapper unionscreeningMapper;

    // 监听主题 async-task-topic

    private static final Logger log = LoggerFactory.getLogger(KafkaAsyncTaskConsumer.class);

    @KafkaListener(topics = "async-task-topic", groupId = "ruoyi-prod-group")
    public void handleAsyncTask(String command) {
        // 解析命令并执行
        if (command.startsWith("sendEmail|@|")) {
            // 移除命令前缀
            String content = command.substring("sendEmail|@|".length());

            // 使用安全分隔符拆分参数
            String[] parts = content.split("\\|@\\|", 2); // 限制分割次数为2

            if (parts.length == 2) {
                String jsondata = parts[0];
                String appkey = parts[1];

                // 将jsondata转为json对象
                JSONObject data = JSONObject.parseObject(jsondata);
//                log.info("--------接收到的数据为：" + data);

                // 服务处理
//            emailService.sendWelcomeEmail(username); // 实际耗时操作
//                System.out.println(appkey);
                // 方法开始时间
                long startTime = System.currentTimeMillis();
                System.out.println("请求开始时间：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss sss").format(new Date()));
                //根据拦截器校验token时，存入ThreadLocal中的appKey,查询用户信息
                SysUserLoginDTO userMap = getAppSecret(appkey);
                String curYear = ""; //测试数据所属的测试年份
                //查询token对应的监测点testPoint
                Long orgId = userMap.getDeptId();

                //整表上传数据entiretyData
                JSONObject entiretyData = (JSONObject) data.get("entirety");

                List<TestWholeData> testWholeList = new ArrayList<>();
//                List<TestWholeDataRetest> testWholeDataRetestList = new ArrayList<>();


                //批量插入数据库方法的参数paramMap
                Map<String, Object> paramMap = new HashMap<>();
                //批量插入数据库的条数pointsDataLimit
                int pointsDataLimit = 100;
                String testWholeDataTableName = ""; //完整测试数据表名
                String testWholeDataRetestTableName; //完整测试数据复测数据表名
                //整表上传数据不为空
                //接收整表信息
                int listSize;
                int maxSize;

                if (entiretyData != null) {
                    //完整会员测试数据
                    // 在解析前注册自定义反序列化器
                    ParserConfig.getGlobalInstance().putDeserializer(String.class, new NullStringDeserializer());

                    // 然后正常解析
                    List<MembersDataDTO> membersData = entiretyData.getJSONArray("membersData")
                            .toJavaList(MembersDataDTO.class);
                    //复测数据
                    List<MembersDataEntityDTO> testCorporeityResultsRetest = entiretyData.getJSONArray("testCorporeityResultsretest").toJavaList(MembersDataEntityDTO.class);
                    // 解析完成后移除自定义反序列化器（避免影响其他解析）
                    ParserConfig.getGlobalInstance().putDeserializer(Object.class, null);

                    if (null != membersData && !membersData.isEmpty()) {
                        //校验token
                        curYear = membersData.get(0).getTestDate().substring(0, 4);
                    }
                    TTestPointInfoDTO testPoint = uploadMapper.selectTTestPointInfoList(curYear, orgId);
                    if (null == testPoint) {
                        //todo 提示用户该监测点不存在
                        log.info("无该监测点信息");
                    }
                    //该抽样点是否需要校验手工录入数据，isCheckRetest为0，不需要校验，isCheckRetest为1，需要校验
                    String isCheckRetest = testPoint.getIsCheckRetest();
                    //查询当前数据年份对应的数据表标识符
                    SysDict dictYear = dictMapper.selectDictByLabel(curYear);
                    //根据年份生成对应的表名
                    testWholeDataTableName = Global.DATATABLEPRE + "_" + dictYear.getValue() + Global.TESTWHOLEDATANAME;
                    testWholeDataRetestTableName = Global.DATATABLEPRE + "_" + dictYear.getValue() + Global.RETESTWHOLEDATANAME;

                    //解析数据
                    TestWholeData testWholeData;
                    if (membersData != null) {
                        System.out.println("正在批量接收测试数据，数据为：" + membersData.size());
                        for (MembersDataDTO map : membersData) {
                            //该抽样点是否需要校验手工录入数据，isCheckRetest为0，不需要校验，isCheckRetest为1，需要校验
                            //手工录入标识是1，手工录入数据不接受
                            if ("1".equals(isCheckRetest)) {
                                if (map.getValueFour() == 1) {
                                    continue;
                                }
                            }
                            try {
                                testWholeData = getTestWholeData(map);
                                testWholeList.add(testWholeData);
                            } catch (Exception e) {
                                log.info("会员数据处理异常：" + map);
                                e.printStackTrace();
                            }
                        }
                    }
                    //解析复测数据,同一个会员同一天只保留一次复测数据，如果存在会更新，不存在插入
                    if (null != testCorporeityResultsRetest && !testCorporeityResultsRetest.isEmpty()) {
                        System.out.println("正在批量接收复测数据：数量为：" + testCorporeityResultsRetest.size());
                        List<TestWholeDataRetest> testCorporeityResultsretestList = new ArrayList<>();
                        TestWholeDataRetest testWholeDataRetest;
                        for (MembersDataEntityDTO map : testCorporeityResultsRetest) {
                            try {
                                testWholeDataRetest = getTestWholeDataRetest(map);
                                testCorporeityResultsretestList.add(testWholeDataRetest);
                            } catch (Exception ignored) {
                                log.info("会员复测数据处理异常：" + map);
                            }
                        }

                        //插入数据库
                        //批量插入数据库
                        listSize = testCorporeityResultsretestList.size();
                        maxSize = listSize - 1;
                        List<TestWholeDataRetest> retestNewList = new ArrayList<>();//新建一个载体list
                        for (int i = 0; i < listSize; i++) {
                            //分批次处理
                            retestNewList.add(testCorporeityResultsretestList.get(i));//循环将数据填入载体list
                            if (pointsDataLimit == retestNewList.size() || i == maxSize) {  //载体list达到要求,进行批量操作
                                paramMap.clear();
                                paramMap.put("tableName", testWholeDataRetestTableName);
                                paramMap.put("list", retestNewList);
                                //调用批量插入,批量插入时，idcard,testtime,若存在则更新,这里复测数据还是一个人，一天只能有一条记录，如果有多次复测记录会覆盖
                                testWholeDataRetestMapper.batchInsert(paramMap);
                                retestNewList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
                            }
                        }
                    }
                } else {
                    log.error("无数据可解析，上传失败");
                }

                //插入数据库
                //批量插入数据库
                listSize = testWholeList.size();
                maxSize = listSize - 1;
                List<TestWholeData> newList = new ArrayList<>();//新建一个载体list
                for (int i = 0; i < listSize; i++) {
                    //分批次处理
                    newList.add(testWholeList.get(i));//循环将数据填入载体list
                    if (pointsDataLimit == newList.size() || i == maxSize) {  //载体list达到要求,进行批量操作
                        paramMap.clear();
                        paramMap.put("tableName", testWholeDataTableName);
                        paramMap.put("list", newList);
                        //调用批量插入,批量插入时，idcard,testtime,若存在则更新
                        testWholeDataMapper.batchInsert(paramMap);
                        newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
                    }
                }
                System.out.println("整表批量插入完成时间：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

                //批量质控
                //查出所有人群类型（幼儿，成年人，老年人），按照人群类型进行逻辑筛查
                List<TPeopleType> peopleTypeList = peopleTypeMapper.getAllList();

                System.out.println("开始整表质量筛查: " + LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));

                processQualityScreening(testWholeDataTableName, peopleTypeList);

                // 方法结束时间
                long endTime = System.currentTimeMillis();
                // 显示所用时间
                System.out.println("----批量处理数据所用时间：" + (endTime - startTime) + "毫秒");

                System.out.println("分表上传处理完成时间：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

            }
        }
    }

    @KafkaListener(topics = "async-Token-topic", groupId = "ruoyi-prod-group")
    public void handleAsyncTaskToken(String command) {
        // 解析命令并执行
        if (command.startsWith("sendEmail|@|")) {
            // 移除命令前缀
            String content = command.substring("sendEmail|@|".length());

            // 使用安全分隔符拆分参数
            String[] parts = content.split("\\|@\\|", 2); // 限制分割次数为2

            if (parts.length == 2) {
                String jsondata = parts[0];
                String token = parts[1];

                // 将jsondata转为json对象
                JSONObject data = JSONObject.parseObject(jsondata);
//                log.info("--------接收到的数据为：" + data);

                // 服务处理
//            emailService.sendWelcomeEmail(username); // 实际耗时操作
//                System.out.println(appkey);
                // 方法开始时间
                long startTime = System.currentTimeMillis();
                System.out.println("请求开始时间：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss sss").format(new Date()));
                //根据拦截器校验token时，存入ThreadLocal中的appKey,查询用户信息
                TTestPointInfoDTO testPoint = uploadMapper.selectTTestPointInfoByToken(token);
                String curYear = ""; //测试数据所属的测试年份
                //查询token对应的监测点testPoint

                //分表上传数据aloneData
                JSONObject aloneData = (JSONObject) data.get("alone");
                //整表上传数据entiretyData
                JSONObject entiretyData = (JSONObject) data.get("entirety");

                List<TestWholeData> testWholeList = new ArrayList<>();
                List<TestWholeDataRetest> testWholeDataRetestList = new ArrayList<>();


                //批量插入数据库方法的参数paramMap
                Map<String, Object> paramMap = new HashMap<>();
                //批量插入数据库的条数pointsDataLimit
                int pointsDataLimit = 100;
                String testWholeDataTableName = ""; //完整测试数据表名
                String testWholeDataRetestTableName; //完整测试数据复测数据表名
                //整表上传数据不为空
                //接收整表信息
                if (aloneData != null) {
                    int listSize;
                    int maxSize;
                    //分表上传数据不为空
                    //接收分表信息并合并

//                    System.out.println("请求开始时间：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
                    ParserConfig.getGlobalInstance().putDeserializer(String.class, new NullStringDeserializer());
                    // 1. 会员信息
                    List<TestMemberDTO> members = aloneData.getJSONArray("members").toJavaList(TestMemberDTO.class);
//                        System.out.println("-----0----正在批量接收会员信息：数量为：" + members.size());

                    // 2. 获取各测试数据
                    List<Map<String, Object>> testCorporeityResults = (List<Map<String, Object>>) aloneData.get("testCorporeityResults");
                    List<Map<String, Object>> testCorporeityResultsretest = (List<Map<String, Object>>) aloneData.get("testCorporeityResultsretest");
                    List<Map<String, Object>> testTurgoscopeResults = (List<Map<String, Object>>) aloneData.get("testTurgoscopeResult");
                    List<Map<String, Object>> testBodyFatResults = (List<Map<String, Object>>) aloneData.get("testBodyFatResult");
                    List<Map<String, Object>> testPowerResults = (List<Map<String, Object>>) aloneData.get("testPowerResult");
                    List<Map<String, Object>> testPowerHeartrateResults = (List<Map<String, Object>>) aloneData.get("testPowerHeartrateResult");

                        /*                       System.out.println("-----1----测试数据: " + testCorporeityResults.size());
                        System.out.println("-----3----复测数据: " + testCorporeityResultsretest.size());
                        System.out.println("-----2----血压数据: " + testTurgoscopeResults.size());
                        System.out.println("-----4----体脂数据: " + testBodyFatResults.size());
                        System.out.println("-----5----功率数据: " + testPowerResults.size());
                        System.out.println("-----6----心率数据: " + testPowerHeartrateResults.size());*/

                    // 3. 获取测试年份
                    if (testCorporeityResults != null && !testCorporeityResults.isEmpty()) {
                        curYear = extractTestYear(testCorporeityResults, "TestCorporeityResults");
                    }
                    if (StringUtils.isEmpty(curYear) && testTurgoscopeResults != null && !testTurgoscopeResults.isEmpty()) {
                        curYear = extractTestYear(testTurgoscopeResults, "TestTurgoscopeResults");
                    }
                    if (StringUtils.isEmpty(curYear) && testBodyFatResults != null && !testBodyFatResults.isEmpty()) {
                        curYear = extractTestYear(testBodyFatResults, "TestBodyFatResults");
                    }
                    if (StringUtils.isEmpty(curYear) && testPowerResults != null && !testPowerResults.isEmpty()) {
                        curYear = extractTestYear(testPowerResults, "TestPowerResults");
                    }

                    ParserConfig.getGlobalInstance().putDeserializer(Object.class, null);

                    // 4. 获取监测点信息
                    if (testPoint == null) {
                        log.error("-------------------该监测点不存在");
                    }

                    // 获取是否需要复测标识以及当前年份对应的字典值，用于构造测试数据表名
                    String isCheckRetest = testPoint.getIsCheckRetest();
                    SysDict dictYear = dictMapper.selectDictByLabel(curYear);
                    testWholeDataTableName = Global.DATATABLEPRE + "_" + dictYear.getValue() + Global.TESTWHOLEDATANAME;
                    testWholeDataRetestTableName = Global.DATATABLEPRE + "_" + dictYear.getValue() + Global.RETESTWHOLEDATANAME;

                    // 5. 会员信息去重：根据身份证号去重，保留首次出现的记录
                    List<TestMemberDTO> uniqueMembers = members.stream()
                            .collect(Collectors.collectingAndThen(
                                    Collectors.toMap(
                                            TestMemberDTO::getIdcard,
                                            Function.identity(),
                                            (existing, replacement) -> existing
                                    ),
                                    map -> new ArrayList<>(map.values())
                            ));
                    System.out.println("会员信息去重后: " + uniqueMembers.size());

                    // 6. 处理各类测试数据，并按身份证号进行分组

                    // 国民体质数据处理
                    Map<String, List<TestCorporeityDTO>> guomintizhiMap = processGuomintizhi(isCheckRetest, testCorporeityResults);
                    System.out.println("国民体质数据: " + guomintizhiMap.size());

                    // 国民体质复测数据处理
                    Map<String, List<TestCorporeityDTO>> testCorporeityRetestMap = groupByIdcard(
                            extractInnerDataWithGPS(testCorporeityResultsretest, "TestCorporeityResultCopies"),
                            TestCorporeityDTO.class,
                            null
                    );
                    System.out.println("国民体质复测数据: " + testCorporeityRetestMap.size());

                    // 血压数据处理
                    Map<String, List<TestTurgoscopeDTO>> testTurgoscopeMap = groupByIdcard(
                            extractInnerDataWithGPS(testTurgoscopeResults, "TestTurgoscopeResults"),
                            TestTurgoscopeDTO.class,
                            isCheckRetest
                    );
                    System.out.println("血压数据: " + testTurgoscopeMap.size());

                    // 体脂数据处理
                    Map<String, List<TestBodyfatDTO>> testBodyfatMap = groupByIdcard(
                            extractInnerDataWithGPS(testBodyFatResults, "TestBodyFatResults"),
                            TestBodyfatDTO.class,
                            isCheckRetest
                    );
                    System.out.println("体脂数据: " + testBodyfatMap.size());

                    // 功率数据处理
                    Map<String, List<TestPowerDTO>> testPowerMap = groupByIdcard(
                            extractInnerDataWithGPS(testPowerResults, "TestPowerResults"),
                            TestPowerDTO.class,
                            isCheckRetest
                    );
                    System.out.println("功率数据: " + testPowerMap.size());

                    // 心率数据处理
                    Map<String, List<TestPowerHeartrateDTO>> testPowerHeartrateMap = groupByIdcard(
                            extractInnerDataWithGPS(testPowerHeartrateResults, "TestPowerHeartrates"),
                            TestPowerHeartrateDTO.class,
                            isCheckRetest
                    );
                    System.out.println("心率数据: " + testPowerHeartrateMap.size());

                    // 按身份证号进行分组遍历，整合每位会员的各类测试数据
                    for (TestMemberDTO member : uniqueMembers) {
                        String idcard = member.getIdcard();

                        // 从各个Map中获取当前会员的各类测试数据
                        List<TestCorporeityDTO> testCorporeity = guomintizhiMap.get(idcard);
                        List<TestTurgoscopeDTO> testTurgoscopeList = testTurgoscopeMap.get(idcard);
                        List<TestBodyfatDTO> testbodyfatList = testBodyfatMap.get(idcard);
                        List<TestPowerDTO> testPowerList = testPowerMap.get(idcard);
                        List<TestPowerHeartrateDTO> testPowerHeartrateList = testPowerHeartrateMap.get(idcard);
                        List<TestCorporeityDTO> testCorporeityRetest = testCorporeityRetestMap.get(idcard);

                        // 创建按testTime分组的组合数据Map，用于整合同一时间点的多种测试数据
                        Map<String, CombinedTestData> combinedDataMap = new HashMap<>();

                        // 1. 统一处理所有数据类型，填充到combinedDataMap中

                        // 处理国民体质数据
                        processTestData(combinedDataMap, testCorporeity, dto -> {
                            CombinedTestData combined = combinedDataMap.computeIfAbsent(dto.getTestTime(), CombinedTestData::new);
                            combined.addCorporeity(dto);
                        });

                        // 处理血压数据
                        processSingleTestData(combinedDataMap, testTurgoscopeList,
                                CombinedTestData::getTurgoscope, CombinedTestData::setTurgoscope);

                        // 处理体脂数据
                        processSingleTestData(combinedDataMap, testbodyfatList,
                                CombinedTestData::getBodyfat, CombinedTestData::setBodyfat);

                        // 处理功率数据
                        processSingleTestData(combinedDataMap, testPowerList,
                                CombinedTestData::getPower, CombinedTestData::setPower);

                        // 处理心率数据
                        processSingleTestData(combinedDataMap, testPowerHeartrateList,
                                CombinedTestData::getPowerHeartrate, CombinedTestData::setPowerHeartrate);


                        // 打印统计数据（不创建临时集合）
                        long start = System.currentTimeMillis();
//                            long completeCount = combinedDataMap.values().stream()
//                                    .filter(CombinedTestData::isComplete).count();
//                            System.out.println("----处理完整数据: " + completeCount);
//                            System.out.println("----处理不完整数据: " + (combinedDataMap.size() - completeCount));

// 并行处理所有数据
                        List<TestWholeData> finalTestWholeList = Collections.synchronizedList(new ArrayList<>()); // 线程安全集合

                        combinedDataMap.values().stream() // 先使用顺序流便于调试
                                .forEach(combinedData -> {
                                    try {
                                        // 3. 为每个数据创建独立处理上下文
                                        TestWholeData testWholeData = new TestWholeData();

                                        // 4. 打印当前处理的数据ID
//                                            System.out.println("处理数据: " + combinedData.getTestTime());

                                        // 5. 设置公共字段
                                        testWholeData.setStatus(1);
                                        testWholeData.setIdcard(idcard);
                                        setmembers(testWholeData, member);

                                        // 6. 安全处理测试年龄
                                        Double testAge = getFirstValidTestAge(
                                                combinedData.getCorporeity(),
                                                combinedData.getTurgoscope(),
                                                combinedData.getBodyfat(),
                                                combinedData.getPower(),
                                                combinedData.getPowerHeartrate()
                                        );
                                        testWholeData.setTestage(toSafeFloat(testAge));

                                        testWholeData.setTesttime(combinedData.getTestTime());
                                        testWholeData.setTestmonth(truncateToMonthWithoutZeroPadFast(combinedData.getTestTime()));
                                        testWholeData.setType(1);

                                        // 7. 使用局部变量而非共享数组
                                        String gps = "0.000,0.000";

                                        // 8. 处理体测数据 - 添加空检查
                                        List<TestCorporeityDTO> corporeitys = combinedData.getCorporeity();
                                        if (corporeitys != null && !corporeitys.isEmpty()) {
                                            gps = processCorporeitys(testWholeData, corporeitys); // 修改为返回GPS的方法
                                        }
                                        testWholeData.setGps(gps);

                                        // 9. 处理功率车数据 - 添加空检查
                                        TestPowerDTO power = combinedData.getPower();
                                        if (power != null) {
                                            testWholeData.setMetval(toSafeFloat(power.getMetvalue()));
                                            testWholeData.setRelativeval(toSafeFloat(power.getRelativevalue()));
                                            testWholeData.setAbsoluteval(toSafeFloat(power.getAbsolutevalue()));

                                            // 10. 安全处理心率
                                            String heartRate = getheartRate(power.getGlcHeartRate(), combinedData.getPowerHeartrate());
                                            testWholeData.setGlcHeartRate(heartRate);

                                            testWholeData.setGlcspecifictime(StringUtils.trimToEmpty(power.getSpecifictime()));
                                            testWholeData.setGlctablegps(StringUtils.trimToEmpty(power.getGps()));
                                        }

                                        // 11. 处理血压计数据 - 重构逻辑
                                        TestTurgoscopeDTO turgoscope = combinedData.getTurgoscope();
                                        if (turgoscope != null) {
                                            // 添加空指针保护
                                            Integer heartrate = turgoscope.getHeartrate();
                                            if (heartrate == null) {
                                                // 安全处理年龄
//                                                    Float turgoscopeAge = toSafeFloat(turgoscope.getTestage());
                                                if (turgoscope.getTestage() != null && isAgeAboveThreshold(turgoscope.getTestage(), 20.0f)) {
                                                    testWholeData.setStatus(0);
                                                }
                                            } else {
                                                testWholeData.setHeartrate(heartrate);
                                                testWholeData.setDiastolicpressure(turgoscope.getDiastolicpressure());
                                                testWholeData.setSystolicpressure(turgoscope.getSystolicpressure());
                                                testWholeData.setXyjspecifictime(StringUtils.trimToEmpty(turgoscope.getSpecifictime()));
                                                testWholeData.setXyjgps(StringUtils.trimToEmpty(turgoscope.getGps()));
                                            }
                                        }

                                        // 12. 处理体脂数据
                                        TestBodyfatDTO bodyfat = combinedData.getBodyfat();
                                        if (bodyfat != null) {
                                            setbodyfat(testWholeData, bodyfat);
                                        }

                                        // 13. 添加到结果集
                                        finalTestWholeList.add(testWholeData);
//                                            System.out.println("成功处理数据: " + combinedData.getTestTime());

                                    } catch (Exception e) {
                                        // 14. 详细记录异常
                                        log.error("处理数据异常: " + combinedData);
                                        System.err.println("处理数据失败: " + combinedData);
                                        e.printStackTrace();
                                    }
                                });
                        testWholeList.addAll(finalTestWholeList);
                        System.out.println("数据处理完成，耗时: " + (System.currentTimeMillis() - start) + "ms");
                        Map<String, CombinedTestData> combinedRetestDataMap = new HashMap<>();

                        // 合并国民体质复测数据
                            /*if (testCorporeityRetest != null && !testCorporeityRetest.isEmpty()) {

                                for (TestCorporeityDTO dto : testCorporeityRetest) {
                                    String time = dto.getTestTime();
                                    CombinedTestData combined = combinedRetestDataMap.computeIfAbsent(time, CombinedTestData::new);
                                    combined.addCorporeity(dto);
                                }
                                for (CombinedTestData fulldata : combinedRetestDataMap.values()) {
                                    System.out.println("完整复测测试数据 - 时间: " + fulldata.getTestTime());
                                    List<TestCorporeityDTO> testCorporeityRetestList = fulldata.getCorporeity();
                                    // 创建完整复测测试数据
                                    TestWholeDataRetest testWholeDataRetest = new TestWholeDataRetest();
                                    testWholeDataRetest.setSex(member.getSex());
                                    testWholeDataRetest.setIdcard(idcard);
                                    testWholeDataRetest.setTowncountry(StringUtils.trimToEmpty(member.getTownAndCountry()));
                                    testWholeDataRetest.setMechanismcode(StringUtils.trimToEmpty(member.getMechanismcode()));
                                    testWholeDataRetest.setTestage(toSafeFloat(testCorporeityRetestList.get(0).getTestAge()));
                                    testWholeDataRetest.setTesttime(fulldata.getTestTime());
                                    testWholeDataRetest.setTestmonth(truncateToMonthWithoutZeroPadFast(fulldata.getTestTime()));
                                    testWholeDataRetest.setGps(StringUtils.trimToEmpty(testCorporeityRetestList.get(0).getGps()));


                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 1)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setShengaoval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setShengaoscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setShengaograde(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setShengaotime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 3)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setZuogaoval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setZuogaoscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setZuogaograde(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setZuogaotime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 2)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setTizhongval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setTizhongtime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 4)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setTzzsval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setTzzsscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setTzzsgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setTzzstime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 8)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setTzlval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setTzlscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setTzlgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setTzltime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 5)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setXiongweival(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setXiongweiscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setXiongweigrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setXiongweitime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 6)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setYaoweival(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setYaoweiscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setYaoweigrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setYaoweitime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 7)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setTunweival(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setTunweiscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setTunweigrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setTunweitime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 9)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setFhlval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setFhlscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setFhlgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setFhltime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 10)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setGlcval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setGlcscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setGlcgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setGlctime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 11)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setLfzydgttval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setLfzydgttscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setLfzydgttgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setLfzydgtttime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 31)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setLfzydgttzval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setLfzydgttztime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 32)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setLfzydgttyval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setLfzydgttytime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 12)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setAjxlval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setAjxlscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setAjxlgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setAjxltime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 13)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setWolival(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setWoliscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setWoligrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setWolitime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 14)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setZongtiaoval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setZongtiaoscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setZongtiaograde(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setZongtiaotime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 15)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setFwcval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setFwcscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setFwcgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setFwctime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 16)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setGwcval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setGwcscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setGwcgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setGwctime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 17)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setYfzywqzval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setYfzywqzscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setYfzywqzgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setYfzywqztime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 18)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setZwtqqval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setZwtqqscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setZwtqqgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setZwtqqtime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 19)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setBydjzlval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setBydjzlscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setBydjzlgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setBydjzltime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 20)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setXzfysval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setXzfysscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setXzfysgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setXzfystime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 21)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setBeilival(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setBeiliscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setBeiligrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setBeilitime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 22)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setSsmzzval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setSsmzzscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setSsmzzgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setSsmzztime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 23)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setLdtyval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setLdtyscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setLdtygrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setLdtytime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 24)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setSjlxtval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setSjlxtscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setSjlxtgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setSjlxttime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 25)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setSwmrzapval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setSwmrzapscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setSwmrzapgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setSwmrzaptime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 26)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                testWholeDataRetest.setZphmval(toSafeFloat(corporeityRetest.getTestValue()));
                                                testWholeDataRetest.setZphmscore(toSafeFloat(corporeityRetest.getScore()));
                                                testWholeDataRetest.setZphmgrade(StringUtils.trimToEmpty(corporeityRetest.getGrade()));
                                                testWholeDataRetest.setZphmtime(StringUtils.trimToEmpty(corporeityRetest.getSpecificTime()));
                                                testWholeDataRetest.setZphmnb(corporeityRetest.getValueOne() == null ? "" : corporeityRetest.getValueOne().toString());
                                            });
                                    testCorporeityRetestList.stream()
                                            .filter(c -> c.getItemCode() == 100)
                                            .findFirst() // 获取第一个匹配项（如需所有匹配项则用forEach）
                                            .ifPresent(corporeityRetest -> {
                                                if (StringUtils.isNotEmpty(corporeityRetest.getScore().toString())) {
                                                    //综合得分不为空，表明参与评价的指标测试完成
                                                    testWholeDataRetest.setZonghescore(toSafeFloat(corporeityRetest.getScore()));
                                                    testWholeDataRetest.setZonghegrade(corporeityRetest.getGrade());
                                                }
                                            });

                                    //是否复测通过;默认复测通过，后期根据需要调整
                                    testWholeDataRetest.setIspassretest(1);
                                    //是否国测
                                    testWholeDataRetest.setType(1);
                                    testWholeDataRetestList.add(testWholeDataRetest);
                                }
                                //插入数据库
                                //批量插入数据库
                                listSize = testWholeDataRetestList.size();
                                maxSize = listSize - 1;
                                List<TestWholeDataRetest> retestNewList = new ArrayList<>();//新建一个载体list
                                for (int i = 0; i < listSize; i++) {
                                    //分批次处理
                                    retestNewList.add(testWholeDataRetestList.get(i));//循环将数据填入载体list
                                    if (pointsDataLimit == retestNewList.size() || i == maxSize) {  //载体list达到要求,进行批量操作
                                        paramMap.clear();
                                        paramMap.put("tableName", testWholeDataRetestTableName);
                                        paramMap.put("list", retestNewList);
                                        //调用批量插入,批量插入时，idcard,testtime,若存在则更新,这里复测数据还是一个人，一天只能有一条记录，如果有多次复测记录会覆盖
                                        testWholeDataRetestMapper.batchInsert(paramMap);
                                        retestNewList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
                                    }
                                }
                            }*/
                        if (testCorporeityRetest != null && !testCorporeityRetest.isEmpty()) {
                            // 预先创建项目代码到DTO的映射 (一次性处理)
                            Map<String, Map<Integer, TestCorporeityDTO>> timeItemMap = testCorporeityRetest.stream()
                                    .collect(Collectors.groupingBy(
                                            TestCorporeityDTO::getTestTime,
                                            Collectors.toMap(
                                                    TestCorporeityDTO::getItemCode,
                                                    Function.identity(),
                                                    (first, second) -> first)  // 重复键取第一个
                                    ));

                            // 准备批量插入列表
                            List<TestWholeDataRetest> batchInsertList = new ArrayList<>();

                            for (Map.Entry<String, Map<Integer, TestCorporeityDTO>> entry : timeItemMap.entrySet()) {
                                String time = entry.getKey();
                                Map<Integer, TestCorporeityDTO> itemMap = entry.getValue();

                                CombinedTestData combined = combinedRetestDataMap.computeIfAbsent(time, CombinedTestData::new);

                                // 逐个添加DTO到CombinedTestData
                                for (TestCorporeityDTO dto : itemMap.values()) {
                                    combined.addCorporeity(dto);
                                }

                                // 创建完整复测测试数据
                                TestWholeDataRetest testWholeDataRetest = new TestWholeDataRetest();
                                testWholeDataRetest.setSex(member.getSex());
                                testWholeDataRetest.setIdcard(idcard);
                                testWholeDataRetest.setTowncountry(StringUtils.trimToEmpty(member.getTownAndCountry()));
                                testWholeDataRetest.setMechanismcode(StringUtils.trimToEmpty(member.getMechanismcode()));

                                // 获取第一个DTO作为基础数据
                                TestCorporeityDTO firstDto = itemMap.values().iterator().next();
                                testWholeDataRetest.setTestage(toSafeFloat(firstDto.getTestAge()));
                                testWholeDataRetest.setTesttime(time);
                                testWholeDataRetest.setTestmonth(truncateToMonthWithoutZeroPadFast(time));
                                testWholeDataRetest.setGps(StringUtils.trimToEmpty(firstDto.getGps()));

                                // 使用重载的applyItemData方法设置各项数据
                                applyItemData(itemMap.get(1),
                                        testWholeDataRetest::setShengaoval,
                                        testWholeDataRetest::setShengaoscore,
                                        testWholeDataRetest::setShengaograde,
                                        testWholeDataRetest::setShengaotime);

                                applyItemData(itemMap.get(3),
                                        testWholeDataRetest::setZuogaoval,
                                        testWholeDataRetest::setZuogaoscore,
                                        testWholeDataRetest::setZuogaograde,
                                        testWholeDataRetest::setZuogaotime);

                                // 项目2只有值和时间
                                applyItemData(itemMap.get(2),
                                        testWholeDataRetest::setTizhongval,
                                        testWholeDataRetest::setTizhongtime);

                                applyItemData(itemMap.get(4),
                                        testWholeDataRetest::setTzzsval,
                                        testWholeDataRetest::setTzzsscore,
                                        testWholeDataRetest::setTzzsgrade,
                                        testWholeDataRetest::setTzzstime);

                                applyItemData(itemMap.get(8),
                                        testWholeDataRetest::setTzlval,
                                        testWholeDataRetest::setTzlscore,
                                        testWholeDataRetest::setTzlgrade,
                                        testWholeDataRetest::setTzltime);

                                // 项目5只有值和时间
                                applyItemData(itemMap.get(5),
                                        testWholeDataRetest::setXiongweival,
                                        testWholeDataRetest::setXiongweitime);

                                // 项目6只有值和时间
                                applyItemData(itemMap.get(6),
                                        testWholeDataRetest::setYaoweival,
                                        testWholeDataRetest::setYaoweitime);

                                applyItemData(itemMap.get(7),
                                        testWholeDataRetest::setTunweival,
                                        testWholeDataRetest::setTunweiscore,
                                        testWholeDataRetest::setTunweigrade,
                                        testWholeDataRetest::setTunweitime);

                                applyItemData(itemMap.get(9),
                                        testWholeDataRetest::setFhlval,
                                        testWholeDataRetest::setFhlscore,
                                        testWholeDataRetest::setFhlgrade,
                                        testWholeDataRetest::setFhltime);

                                applyItemData(itemMap.get(10),
                                        testWholeDataRetest::setGlcval,
                                        testWholeDataRetest::setGlcscore,
                                        testWholeDataRetest::setGlcgrade,
                                        testWholeDataRetest::setGlctime);

                                applyItemData(itemMap.get(11),
                                        testWholeDataRetest::setLfzydgttval,
                                        testWholeDataRetest::setLfzydgttscore,
                                        testWholeDataRetest::setLfzydgttgrade,
                                        testWholeDataRetest::setLfzydgtttime);

                                // 项目31只有值和时间
                                applyItemData(itemMap.get(31),
                                        testWholeDataRetest::setLfzydgttzval,
                                        testWholeDataRetest::setLfzydgttztime);

                                // 项目32只有值和时间
                                applyItemData(itemMap.get(32),
                                        testWholeDataRetest::setLfzydgttyval,
                                        testWholeDataRetest::setLfzydgttytime);

                                applyItemData(itemMap.get(12),
                                        testWholeDataRetest::setAjxlval,
                                        testWholeDataRetest::setAjxlscore,
                                        testWholeDataRetest::setAjxlgrade,
                                        testWholeDataRetest::setAjxltime);

                                applyItemData(itemMap.get(13),
                                        testWholeDataRetest::setWolival,
                                        testWholeDataRetest::setWoliscore,
                                        testWholeDataRetest::setWoligrade,
                                        testWholeDataRetest::setWolitime);

                                applyItemData(itemMap.get(14),
                                        testWholeDataRetest::setZongtiaoval,
                                        testWholeDataRetest::setZongtiaoscore,
                                        testWholeDataRetest::setZongtiaograde,
                                        testWholeDataRetest::setZongtiaotime);

                                applyItemData(itemMap.get(15),
                                        testWholeDataRetest::setFwcval,
                                        testWholeDataRetest::setFwcscore,
                                        testWholeDataRetest::setFwcgrade,
                                        testWholeDataRetest::setFwctime);

                                applyItemData(itemMap.get(16),
                                        testWholeDataRetest::setGwcval,
                                        testWholeDataRetest::setGwcscore,
                                        testWholeDataRetest::setGwcgrade,
                                        testWholeDataRetest::setGwctime);

                                applyItemData(itemMap.get(17),
                                        testWholeDataRetest::setYfzywqzval,
                                        testWholeDataRetest::setYfzywqzscore,
                                        testWholeDataRetest::setYfzywqzgrade,
                                        testWholeDataRetest::setYfzywqztime);

                                applyItemData(itemMap.get(18),
                                        testWholeDataRetest::setZwtqqval,
                                        testWholeDataRetest::setZwtqqscore,
                                        testWholeDataRetest::setZwtqqgrade,
                                        testWholeDataRetest::setZwtqqtime);

                                applyItemData(itemMap.get(19),
                                        testWholeDataRetest::setBydjzlval,
                                        testWholeDataRetest::setBydjzlscore,
                                        testWholeDataRetest::setBydjzlgrade,
                                        testWholeDataRetest::setBydjzltime);

                                applyItemData(itemMap.get(20),
                                        testWholeDataRetest::setXzfysval,
                                        testWholeDataRetest::setXzfysscore,
                                        testWholeDataRetest::setXzfysgrade,
                                        testWholeDataRetest::setXzfystime);

                                applyItemData(itemMap.get(21),
                                        testWholeDataRetest::setBeilival,
                                        testWholeDataRetest::setBeiliscore,
                                        testWholeDataRetest::setBeiligrade,
                                        testWholeDataRetest::setBeilitime);

                                applyItemData(itemMap.get(22),
                                        testWholeDataRetest::setSsmzzval,
                                        testWholeDataRetest::setSsmzzscore,
                                        testWholeDataRetest::setSsmzzgrade,
                                        testWholeDataRetest::setSsmzztime);

                                applyItemData(itemMap.get(23),
                                        testWholeDataRetest::setLdtyval,
                                        testWholeDataRetest::setLdtyscore,
                                        testWholeDataRetest::setLdtygrade,
                                        testWholeDataRetest::setLdtytime);

                                applyItemData(itemMap.get(24),
                                        testWholeDataRetest::setSjlxtval,
                                        testWholeDataRetest::setSjlxtscore,
                                        testWholeDataRetest::setSjlxtgrade,
                                        testWholeDataRetest::setSjlxttime);

                                applyItemData(itemMap.get(25),
                                        testWholeDataRetest::setSwmrzapval,
                                        testWholeDataRetest::setSwmrzapscore,
                                        testWholeDataRetest::setSwmrzapgrade,
                                        testWholeDataRetest::setSwmrzaptime);

                                // 特殊处理项目26
                                TestCorporeityDTO item26 = itemMap.get(26);
                                if (item26 != null) {
                                    testWholeDataRetest.setZphmval(toSafeFloat(item26.getTestValue()));
                                    testWholeDataRetest.setZphmscore(toSafeFloat(item26.getScore()));
                                    testWholeDataRetest.setZphmgrade(StringUtils.trimToEmpty(item26.getGrade()));
                                    testWholeDataRetest.setZphmtime(StringUtils.trimToEmpty(item26.getSpecificTime()));
                                    testWholeDataRetest.setZphmnb(item26.getValueOne() == null ? "" : item26.getValueOne().toString());
                                }

                                // 处理综合得分(100)
                                TestCorporeityDTO item100 = itemMap.get(100);
                                if (item100 != null) {
                                    if (StringUtils.isNotEmpty(item100.getScore().toString())) {
                                        testWholeDataRetest.setZonghescore(toSafeFloat(item100.getScore()));
                                        testWholeDataRetest.setZonghegrade(item100.getGrade());
                                    }
                                }

                                testWholeDataRetest.setIspassretest(1);
                                testWholeDataRetest.setType(1);

                                // 添加到批量列表
                                batchInsertList.add(testWholeDataRetest);
                            }

                            // 批量插入优化（使用分页批处理）
                            int batchSize = 500; // 根据DB性能调整
                            for (int i = 0; i < batchInsertList.size(); i += batchSize) {
                                int end = Math.min(i + batchSize, batchInsertList.size());
                                List<TestWholeDataRetest> batchList = batchInsertList.subList(i, end);

                                Map<String, Object> reparamMap = new HashMap<>();
                                reparamMap.put("tableName", testWholeDataRetestTableName);
                                reparamMap.put("list", batchList);

                                testWholeDataRetestMapper.batchInsert(reparamMap);
                            }
                        }
                    }


                    //插入数据库
                    //批量插入数据库
                    listSize = testWholeList.size();
                    maxSize = listSize - 1;
                    List<TestWholeData> newList = new ArrayList<>();//新建一个载体list
                    for (int i = 0; i < listSize; i++) {
                        //分批次处理
                        newList.add(testWholeList.get(i));//循环将数据填入载体list
                        if (pointsDataLimit == newList.size() || i == maxSize) {  //载体list达到要求,进行批量操作
                            paramMap.clear();
                            paramMap.put("tableName", testWholeDataTableName);
                            paramMap.put("list", newList);
                            //调用批量插入,批量插入时，idcard,testtime,若存在则更新
                            testWholeDataMapper.batchInsert(paramMap);
                            newList.clear();//每次批量操作后,清空载体list,等待下次的数据填入
                        }
                    }
                    System.out.println("整表批量插入完成时间：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

                    //批量质控
                    //查出所有人群类型（幼儿，成年人，老年人），按照人群类型进行逻辑筛查
                    List<TPeopleType> peopleTypeList = peopleTypeMapper.getAllList();

                    System.out.println("开始整表质量筛查: " + LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));

                    processQualityScreening(testWholeDataTableName, peopleTypeList);
                }
                // 方法结束时间
                long endTime = System.currentTimeMillis();
                // 显示所用时间
                System.out.println("----批量处理数据所用时间：" + (endTime - startTime) + "毫秒");

                System.out.println("分表上传处理完成时间：" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

            }
        }
    }

    /**
     * 设置TestWholeData对象的成员属性值
     *
     * @param testWholeData 目标数据对象，用于存储成员信息
     * @param member        源数据对象，提供成员信息
     */
    private void setmembers(TestWholeData testWholeData, TestMemberDTO member) {
        // 设置基本个人信息
        testWholeData.setRealname(member.getName());
        testWholeData.setSex(member.getSex());
        testWholeData.setBirthdate(member.getBirthdate());
        testWholeData.setAge(toSafeFloat(member.getAge()));

        // 设置民族、地址、工作单位等文本信息
        testWholeData.setNation(StringUtils.trimToEmpty(member.getNation()));
        testWholeData.setAddress(StringUtils.trimToEmpty(member.getAddress()));
        testWholeData.setWorkunit(StringUtils.trimToEmpty(member.getWorkunit()));

        // 设置时间戳和状态信息
        testWholeData.setCreatetime(StringUtils.trimToEmpty(member.getCreatetime()));
        testWholeData.setUpdatetime(StringUtils.trimToEmpty(member.getUpdatetime()));
        testWholeData.setDeleted(StringUtils.trimToEmpty(member.getDeleted()));

        // 设置职业相关信息
        testWholeData.setPosition(StringUtils.trimToEmpty(member.getPosition()));
        testWholeData.setOccupation(StringUtils.trimToEmpty(member.getOccupation()));
        testWholeData.setIndustry(StringUtils.trimToEmpty(member.getIndustry()));
        testWholeData.setTowncountry(StringUtils.trimToEmpty(member.getTownAndCountry()));
        testWholeData.setCulture(StringUtils.trimToEmpty(member.getCulture()));

        // 设置联系方式和机构信息
        testWholeData.setPhone(StringUtils.trimToEmpty(member.getPhone()));
        testWholeData.setMechanismname(StringUtils.trimToEmpty(member.getMechanismname()));
        testWholeData.setMechanismcode(StringUtils.trimToEmpty(member.getMechanismcode()));
    }


    /**
     * 处理Corporeity数据，将数据映射到TestWholeData对象中
     *
     * @param testWholeData 整个测试数据对象
     * @param corporeitys   测试数据列表
     * @return 处理后的GPS信息
     */
    private String processCorporeitys(TestWholeData testWholeData, List<TestCorporeityDTO> corporeitys) {
        // 定义处理映射表
        Map<Integer, QuadConsumer<TestWholeData, TestCorporeityDTO>> handlers = new HashMap<>();
        // 初始化为默认GPS值
        String finalGps = "0.000,0.000";

        // 1. 定义所有处理逻辑（使用辅助方法）
        handlers.put(1, (twd, corp) -> {
            twd.setShengaoval(toSafeFloat(corp.getTestValue()));
            twd.setShengaoscore(toSafeFloat(corp.getScore()));
            twd.setShengaograde(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setShengaotime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setShengaogps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(3, (twd, corp) -> {
            twd.setZuogaoval(toSafeFloat(corp.getTestValue()));
            twd.setZuogaoscore(toSafeFloat(corp.getScore()));
            twd.setZuogaograde(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setZuogaotime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setZuogaogps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(2, (twd, corp) -> {
            twd.setTizhongval(toSafeFloat(corp.getTestValue()));
            twd.setTizhongtime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setTizhonggps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(4, (twd, corp) -> {
            twd.setTzzsval(toSafeFloat(corp.getTestValue()));
            twd.setTzzsscore(toSafeFloat(corp.getScore()));
            twd.setTzzsgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setTzzstime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setTzzsgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(8, (twd, corp) -> {
            twd.setTzlval(toSafeFloat(corp.getTestValue()));
            twd.setTzlscore(toSafeFloat(corp.getScore()));
            twd.setTzlgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setTzltime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setTzlgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(5, (twd, corp) -> {
            twd.setXiongweival(toSafeFloat(corp.getTestValue()));
            twd.setXiongweitime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setXiongweigps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(6, (twd, corp) -> {
            twd.setYaoweival(toSafeFloat(corp.getTestValue()));
            twd.setYaoweitime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setYaoweigps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(7, (twd, corp) -> {
            twd.setTunweival(toSafeFloat(corp.getTestValue()));
            twd.setTunweiscore(toSafeFloat(corp.getScore()));
            twd.setTunweigrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setTunweitime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setTunweigps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(9, (twd, corp) -> {
            twd.setFhlval(toSafeFloat(corp.getTestValue()));
            twd.setFhlscore(toSafeFloat(corp.getScore()));
            twd.setFhlgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setFhltime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setFhlgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(10, (twd, corp) -> {
            twd.setGlcval(toSafeFloat(corp.getTestValue()));
            twd.setGlcscore(toSafeFloat(corp.getScore()));
            twd.setGlcgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setGlctime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setGlcgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(11, (twd, corp) -> {
            twd.setLfzydgttval(toSafeFloat(corp.getTestValue()));
            twd.setLfzydgttscore(toSafeFloat(corp.getScore()));
            twd.setLfzydgttgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setLfzydgtttime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setLfzydgttgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(31, (twd, corp) -> {
            twd.setLfzydgttzval(toSafeFloat(corp.getTestValue()));
            twd.setLfzydgttztime(StringUtils.trimToEmpty(corp.getSpecificTime()));
        });

        handlers.put(32, (twd, corp) -> {
            twd.setLfzydgttyval(toSafeFloat(corp.getTestValue()));
            twd.setLfzydgttytime(StringUtils.trimToEmpty(corp.getSpecificTime()));
        });

        handlers.put(12, (twd, corp) -> {
            twd.setAjxlval(toSafeFloat(corp.getTestValue()));
            twd.setAjxlscore(toSafeFloat(corp.getScore()));
            twd.setAjxlgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setAjxltime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setAjxlgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(13, (twd, corp) -> {
            twd.setWolival(toSafeFloat(corp.getTestValue()));
            twd.setWoliscore(toSafeFloat(corp.getScore()));
            twd.setWoligrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setWolitime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setWoligps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(14, (twd, corp) -> {
            twd.setZongtiaoval(toSafeFloat(corp.getTestValue()));
            twd.setZongtiaoscore(toSafeFloat(corp.getScore()));
            twd.setZongtiaograde(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setZongtiaotime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setZongtiaogps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(15, (twd, corp) -> {
            twd.setFwcval(toSafeFloat(corp.getTestValue()));
            twd.setFwcscore(toSafeFloat(corp.getScore()));
            twd.setFwcgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setFwctime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setFwcgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(16, (twd, corp) -> {
            twd.setGwcval(toSafeFloat(corp.getTestValue()));
            twd.setGwcscore(toSafeFloat(corp.getScore()));
            twd.setGwcgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setGwctime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setGwcgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(17, (twd, corp) -> {
            twd.setYfzywqzval(toSafeFloat(corp.getTestValue()));
            twd.setYfzywqzscore(toSafeFloat(corp.getScore()));
            twd.setYfzywqzgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setYfzywqztime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setYfzywqzgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(18, (twd, corp) -> {
            twd.setZwtqqval(toSafeFloat(corp.getTestValue()));
            twd.setZwtqqscore(toSafeFloat(corp.getScore()));
            twd.setZwtqqgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setZwtqqtime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setZwtqqgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(19, (twd, corp) -> {
            twd.setBydjzlval(toSafeFloat(corp.getTestValue()));
            twd.setBydjzlscore(toSafeFloat(corp.getScore()));
            twd.setBydjzlgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setBydjzltime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setBydjzlgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(20, (twd, corp) -> {
            twd.setXzfysval(toSafeFloat(corp.getTestValue()));
            twd.setXzfysscore(toSafeFloat(corp.getScore()));
            twd.setXzfysgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setXzfystime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setXzfysgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(21, (twd, corp) -> {
            twd.setBeilival(toSafeFloat(corp.getTestValue()));
            twd.setBeiliscore(toSafeFloat(corp.getScore()));
            twd.setBeiligrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setBeilitime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setBeiligps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(22, (twd, corp) -> {
            twd.setSsmzzval(toSafeFloat(corp.getTestValue()));
            twd.setSsmzzscore(toSafeFloat(corp.getScore()));
            twd.setSsmzzgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setSsmzztime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setSsmzzgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(23, (twd, corp) -> {
            twd.setLdtyval(toSafeFloat(corp.getTestValue()));
            twd.setLdtyscore(toSafeFloat(corp.getScore()));
            twd.setLdtygrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setLdtytime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setLdtygps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(24, (twd, corp) -> {
            twd.setSjlxtval(toSafeFloat(corp.getTestValue()));
            twd.setSjlxtscore(toSafeFloat(corp.getScore()));
            twd.setSjlxtgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setSjlxttime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setSjlxtgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(25, (twd, corp) -> {
            twd.setSwmrzapval(toSafeFloat(corp.getTestValue()));
            twd.setSwmrzapscore(toSafeFloat(corp.getScore()));
            twd.setSwmrzapgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setSwmrzaptime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setSwmrzapgps(StringUtils.trimToEmpty(corp.getGps()));
        });

        handlers.put(26, (twd, corp) -> {
            twd.setZphmval(toSafeFloat(corp.getTestValue()));
            twd.setZphmscore(toSafeFloat(corp.getScore()));
            twd.setZphmgrade(StringUtils.trimToEmpty(corp.getGrade()));
            twd.setZphmtime(StringUtils.trimToEmpty(corp.getSpecificTime()));
            twd.setZphmgps(StringUtils.trimToEmpty(corp.getGps()));
            twd.setZphmnb(corp.getValueOne() == null ? "" : corp.getValueOne().toString());
        });

        handlers.put(100, (twd, corp) -> {
            // 安全处理空值
            String scoreStr = corp.getScore() == null ? "" : corp.getScore().toString();
            if (StringUtils.isEmpty(scoreStr)) {
                // 该会员没有综合得分，表明该会员参与评价的指标未测试完，测试状态是未完成
                twd.setStatus(0);
            } else {
                // 综合得分不为空，表明参与评价的指标测试完成
                twd.setZonghescore(toSafeFloat(corp.getScore()));
                twd.setZonghegrade(corp.getGrade());
            }
        });

        // 2. 创建已处理标记集
        Set<Integer> processedCodes = new HashSet<>();

        // 3. 单次遍历处理所有逻辑
        for (TestCorporeityDTO corp : corporeitys) {
            int itemCode = corp.getItemCode();

            // 只处理每个itemCode的第一个匹配项
            if (handlers.containsKey(itemCode) && !processedCodes.contains(itemCode)) {
                // 执行主处理逻辑
                handlers.get(itemCode).accept(testWholeData, corp);

                // 4. 更新GPS（除特殊itemCode外）
                if (itemCode != 31 && itemCode != 32 && itemCode != 100) {
                    if (finalGps.equals("0.000,0.000") &&
                            StringUtils.isNotEmpty(corp.getGps())) {
                        finalGps = corp.getGps();
                    }
                }

                // 标记为已处理
                processedCodes.add(itemCode);

                // 所有处理完成时提前退出
                if (processedCodes.size() == handlers.size()) {
                    break;
                }
            }
        }

        // 5. 返回最终确定的GPS值
        return finalGps;
    }

    // 四参数消费者接口定义
    @FunctionalInterface
    interface QuadConsumer<A, B> {
        void accept(A a, B b);
    }

    // 通用DTO数据处理方法
    private void applyItemData(TestCorporeityDTO dto,
                               Consumer<Float> valueSetter,
                               Consumer<Float> scoreSetter,
                               Consumer<String> gradeSetter,
                               Consumer<String> timeSetter) {
        if (dto != null) {
            if (valueSetter != null) valueSetter.accept(toSafeFloat(dto.getTestValue()));
            if (scoreSetter != null) scoreSetter.accept(toSafeFloat(dto.getScore()));
            if (gradeSetter != null) gradeSetter.accept(StringUtils.trimToEmpty(dto.getGrade()));
            if (timeSetter != null) timeSetter.accept(StringUtils.trimToEmpty(dto.getSpecificTime()));
        }
    }

    // 特殊项目处理示例（项目2只有值和时间）
    private void applyItemData(TestCorporeityDTO dto,
                               Consumer<Float> valueSetter,
                               Consumer<String> timeSetter) {
        if (dto != null) {
            if (valueSetter != null) valueSetter.accept(toSafeFloat(dto.getTestValue()));
            if (timeSetter != null) timeSetter.accept(StringUtils.trimToEmpty(dto.getSpecificTime()));
        }
    }

    /**
     * @param testWholeData
     * @param bodyfat
     */
    private void setbodyfat(TestWholeData testWholeData, TestBodyfatDTO bodyfat) {
        testWholeData.setShengao(bodyfat.getSHENGAO() == null ? "" : bodyfat.getSHENGAO().toString());
        testWholeData.setTizhong(bodyfat.getTIZHONG() == null ? "" : bodyfat.getTIZHONG().toString());
        testWholeData.setK1Zongzukang(bodyfat.getK1_ZONGZUKANG() == null ? "" : bodyfat.getK1_ZONGZUKANG().toString());
        testWholeData.setK5Zongzukang(bodyfat.getK5_ZONGZUKANG() == null ? "" : bodyfat.getK5_ZONGZUKANG().toString());
        testWholeData.setK20Zongzukang(bodyfat.getK20_ZONGZUKANG() == null ? "" : bodyfat.getK20_ZONGZUKANG().toString());
        testWholeData.setK50Zongzukang(bodyfat.getK50_ZONGZUKANG() == null ? "" : bodyfat.getK50_ZONGZUKANG().toString());
        testWholeData.setK50Xiangweicha(bodyfat.getK50_XIANGWEICHA() == null ? "" : bodyfat.getK50_XIANGWEICHA().toString());
        testWholeData.setK50Zuoshangzhizukang(bodyfat.getK50_ZUOSHANGZHIZUKANG() == null ? "" : bodyfat.getK50_ZUOSHANGZHIZUKANG().toString());
        testWholeData.setK50Youshangzhizukang(bodyfat.getK50_YOUSHANGZHIZUKANG() == null ? "" : bodyfat.getK50_YOUSHANGZHIZUKANG().toString());
        testWholeData.setK50Quganzukang(bodyfat.getK50_QUGANZUKANG() == null ? "" : bodyfat.getK50_QUGANZUKANG().toString());
        testWholeData.setK50Zuoxiazhizukang(bodyfat.getK50_ZUOXIAZHIZUKANG() == null ? "" : bodyfat.getK50_ZUOXIAZHIZUKANG().toString());
        testWholeData.setK50Youxiazhizukang(bodyfat.getK50_YOUXIAZHIZUKANG() == null ? "" : bodyfat.getK50_YOUXIAZHIZUKANG().toString());
        testWholeData.setK100Zongzukang(bodyfat.getK100_ZONGZUKANG() == null ? "" : bodyfat.getK100_ZONGZUKANG().toString());
        testWholeData.setK250Zongzukang(bodyfat.getK250_ZONGZUKANG() == null ? "" : bodyfat.getK250_ZONGZUKANG().toString());
        testWholeData.setK500Zongzukang(bodyfat.getK500_ZONGZUKANG() == null ? "" : bodyfat.getK500_ZONGZUKANG().toString());
        testWholeData.setK1000Zongzukang(bodyfat.getK1000_ZONGZUKANG() == null ? "" : bodyfat.getK1000_ZONGZUKANG().toString());
        testWholeData.setBztzBiaozhunzhi(bodyfat.getBZTZ_BIAOZHUNZHI() == null ? "" : bodyfat.getBZTZ_BIAOZHUNZHI().toString());
        testWholeData.setBztzXiajie(bodyfat.getBZTZ_XIAJIE() == null ? "" : bodyfat.getBZTZ_XIAJIE().toString());
        testWholeData.setBztzShangjie(bodyfat.getBZTZ_SHANGJIE() == null ? "" : bodyfat.getBZTZ_SHANGJIE().toString());
        testWholeData.setQztzShicezhi(bodyfat.getQZTZ_SHICEZHI() == null ? "" : bodyfat.getQZTZ_SHICEZHI().toString());
        testWholeData.setQztzXiajie(bodyfat.getQZTZ_XIAJIE() == null ? "" : bodyfat.getQZTZ_XIAJIE().toString());
        testWholeData.setQztzShangjie(bodyfat.getQZTZ_SHANGJIE() == null ? "" : bodyfat.getQZTZ_SHANGJIE().toString());
        testWholeData.setTzflShicezhi(bodyfat.getTZFL_SHICEZHI() == null ? "" : bodyfat.getTZFL_SHICEZHI().toString());
        testWholeData.setTzflXiajie(bodyfat.getTZFL_XIAJIE() == null ? "" : bodyfat.getTZFL_XIAJIE().toString());
        testWholeData.setTzflShangjie(bodyfat.getTZFL_SHANGJIE() == null ? "" : bodyfat.getTZFL_SHANGJIE().toString());
        testWholeData.setStjrlShicezhi(bodyfat.getSTJRL_SHICEZHI() == null ? "" : bodyfat.getSTJRL_SHICEZHI().toString());
        testWholeData.setStjrlXiajie(bodyfat.getSTJRL_XIAJIE() == null ? "" : bodyfat.getSTJRL_XIAJIE().toString());
        testWholeData.setStjrlShangjie(bodyfat.getSTJRL_SHANGJIE() == null ? "" : bodyfat.getSTJRL_SHANGJIE().toString());
        testWholeData.setGgjrShicezhi(bodyfat.getGGJR_SHICEZHI() == null ? "" : bodyfat.getGGJR_SHICEZHI().toString());
        testWholeData.setGgjrXiajie(bodyfat.getGGJR_XIAJIE() == null ? "" : bodyfat.getGGJR_XIAJIE().toString());
        testWholeData.setGgjrShangjie(bodyfat.getGGJR_SHANGJIE() == null ? "" : bodyfat.getGGJR_SHANGJIE().toString());
        testWholeData.setStzsfShicezhi(bodyfat.getSTZSF_SHICEZHI() == null ? "" : bodyfat.getSTZSF_SHICEZHI().toString());
        testWholeData.setStzsfXiajie(bodyfat.getSTZSF_XIAJIE() == null ? "" : bodyfat.getSTZSF_XIAJIE().toString());
        testWholeData.setStzsfShangjie(bodyfat.getSTZSF_SHANGJIE() == null ? "" : bodyfat.getSTZSF_SHANGJIE().toString());
        testWholeData.setDbzShicezhi(bodyfat.getDBZ_SHICEZHI() == null ? "" : bodyfat.getDBZ_SHICEZHI().toString());
        testWholeData.setDbzXiajie(bodyfat.getDBZ_XIAJIE() == null ? "" : bodyfat.getDBZ_XIAJIE().toString());
        testWholeData.setDbzShangjie(bodyfat.getDBZ_SHANGJIE() == null ? "" : bodyfat.getDBZ_SHANGJIE().toString());
        testWholeData.setWjyShicezhi(bodyfat.getWJY_SHICEZHI() == null ? "" : bodyfat.getWJY_SHICEZHI().toString());
        testWholeData.setWjyXiajie(bodyfat.getWJY_XIAJIE() == null ? "" : bodyfat.getWJY_XIAJIE().toString());
        testWholeData.setWjyShangjie(bodyfat.getWJY_SHANGJIE() == null ? "" : bodyfat.getWJY_SHANGJIE().toString());
        testWholeData.setXbwyShicezhi(bodyfat.getXBWY_SHICEZHI() == null ? "" : bodyfat.getXBWY_SHICEZHI().toString());
        testWholeData.setXbwyXiajie(bodyfat.getXBWY_XIAJIE() == null ? "" : bodyfat.getXBWY_XIAJIE().toString());
        testWholeData.setXbwyShangjie(bodyfat.getXBWY_SHANGJIE() == null ? "" : bodyfat.getXBWY_SHANGJIE().toString());
        testWholeData.setXbnyShicezhi(bodyfat.getXBNY_SHICEZHI() == null ? "" : bodyfat.getXBNY_SHICEZHI().toString());
        testWholeData.setXbnyXiajie(bodyfat.getXBNY_XIAJIE() == null ? "" : bodyfat.getXBNY_XIAJIE().toString());
        testWholeData.setXbnyShangjie(bodyfat.getXBNY_SHANGJIE() == null ? "" : bodyfat.getXBNY_SHANGJIE().toString());
        testWholeData.setZszjrlShicezhi(bodyfat.getZSZJRL_SHICEZHI() == null ? "" : bodyfat.getZSZJRL_SHICEZHI().toString());
        testWholeData.setZszjrlXiajie(bodyfat.getZSZJRL_XIAJIE() == null ? "" : bodyfat.getZSZJRL_XIAJIE().toString());
        testWholeData.setZszjrlShangjie(bodyfat.getZSZJRL_SHANGJIE() == null ? "" : bodyfat.getZSZJRL_SHANGJIE().toString());
        testWholeData.setYszjrlShicezhi(bodyfat.getYSZJRL_SHICEZHI() == null ? "" : bodyfat.getYSZJRL_SHICEZHI().toString());
        testWholeData.setYszjrlXiajie(bodyfat.getYSZJRL_XIAJIE() == null ? "" : bodyfat.getYSZJRL_XIAJIE().toString());
        testWholeData.setYszjrlShangjie(bodyfat.getYSZJRL_SHANGJIE() == null ? "" : bodyfat.getYSZJRL_SHANGJIE().toString());
        testWholeData.setQgjrlShicezhi(bodyfat.getQGJRL_SHICEZHI() == null ? "" : bodyfat.getQGJRL_SHICEZHI().toString());
        testWholeData.setQgjrlXiajie(bodyfat.getQGJRL_XIAJIE() == null ? "" : bodyfat.getQGJRL_XIAJIE().toString());
        testWholeData.setQgjrlShangjie(bodyfat.getQGJRL_SHANGJIE() == null ? "" : bodyfat.getQGJRL_SHANGJIE().toString());
        testWholeData.setZxzjrlShicezhi(bodyfat.getZXZJRL_SHICEZHI() == null ? "" : bodyfat.getZXZJRL_SHICEZHI().toString());
        testWholeData.setZxzjrlXiajie(bodyfat.getZXZJRL_XIAJIE() == null ? "" : bodyfat.getZXZJRL_XIAJIE().toString());
        testWholeData.setZxzjrlShangjie(bodyfat.getZXZJRL_SHANGJIE() == null ? "" : bodyfat.getZXZJRL_SHANGJIE().toString());
        testWholeData.setYxzjrlShicezhi(bodyfat.getYXZJRL_SHICEZHI() == null ? "" : bodyfat.getYXZJRL_SHICEZHI().toString());
        testWholeData.setYxzjrlXiajie(bodyfat.getYXZJRL_XIAJIE() == null ? "" : bodyfat.getYXZJRL_XIAJIE().toString());
        testWholeData.setYxzjrlShangjie(bodyfat.getYXZJRL_SHANGJIE() == null ? "" : bodyfat.getYXZJRL_SHANGJIE().toString());
        testWholeData.setZszzflShicezhi(bodyfat.getZSZZFL_SHICEZHI() == null ? "" : bodyfat.getZSZZFL_SHICEZHI().toString());
        testWholeData.setZszzflXiajie(bodyfat.getZSZZFL_XIAJIE() == null ? "" : bodyfat.getZSZZFL_XIAJIE().toString());
        testWholeData.setZszzflShangjie(bodyfat.getZSZZFL_SHANGJIE() == null ? "" : bodyfat.getZSZZFL_SHANGJIE().toString());
        testWholeData.setYszzflShicezhi(bodyfat.getYSZZFL_SHICEZHI() == null ? "" : bodyfat.getYSZZFL_SHICEZHI().toString());
        testWholeData.setYszzflXiajie(bodyfat.getYSZZFL_XIAJIE() == null ? "" : bodyfat.getYSZZFL_XIAJIE().toString());
        testWholeData.setYszzflShangjie(bodyfat.getYSZZFL_SHANGJIE() == null ? "" : bodyfat.getYSZZFL_SHANGJIE().toString());
        testWholeData.setQgzflShicezhi(bodyfat.getQGZFL_SHICEZHI() == null ? "" : bodyfat.getQGZFL_SHICEZHI().toString());
        testWholeData.setQgzflXiajie(bodyfat.getQGZFL_XIAJIE() == null ? "" : bodyfat.getQGZFL_XIAJIE().toString());
        testWholeData.setQgzflShangjie(bodyfat.getQGZFL_SHANGJIE() == null ? "" : bodyfat.getQGZFL_SHANGJIE().toString());
        testWholeData.setZxzzflShicezhi(bodyfat.getZXZZFL_SHICEZHI() == null ? "" : bodyfat.getZXZZFL_SHICEZHI().toString());
        testWholeData.setZxzzflXiajie(bodyfat.getZXZZFL_XIAJIE() == null ? "" : bodyfat.getZXZZFL_XIAJIE().toString());
        testWholeData.setZxzzflShangjie(bodyfat.getZXZZFL_SHANGJIE() == null ? "" : bodyfat.getZXZZFL_SHANGJIE().toString());
        testWholeData.setYxzzflShicezhi(bodyfat.getYXZZFL_SHICEZHI() == null ? "" : bodyfat.getYXZZFL_SHICEZHI().toString());
        testWholeData.setYxzzflXiajie(bodyfat.getYXZZFL_XIAJIE() == null ? "" : bodyfat.getYXZZFL_XIAJIE().toString());
        testWholeData.setYxzzflShangjie(bodyfat.getYXZZFL_SHANGJIE() == null ? "" : bodyfat.getYXZZFL_SHANGJIE().toString());
        testWholeData.setTzjgShijizhi(bodyfat.getTZJG_SHIJIZHI() == null ? "" : bodyfat.getTZJG_SHIJIZHI().toString());
        testWholeData.setTzjgXiajie(bodyfat.getTZJG_XIAJIE() == null ? "" : bodyfat.getTZJG_XIAJIE().toString());
        testWholeData.setTzjgShangjie(bodyfat.getTZJG_SHANGJIE() == null ? "" : bodyfat.getTZJG_SHANGJIE().toString());
        testWholeData.setBmiShicezhi(bodyfat.getBMI_SHICEZHI() == null ? "" : bodyfat.getBMI_SHICEZHI().toString());
        testWholeData.setBmiXiajie(bodyfat.getBMI_XIAJIE() == null ? "" : bodyfat.getBMI_XIAJIE().toString());
        testWholeData.setBmiShangjie(bodyfat.getBMI_SHANGJIE() == null ? "" : bodyfat.getBMI_SHANGJIE().toString());
        testWholeData.setZfljgFatW(bodyfat.getZFLJG_FAT_W() == null ? "" : bodyfat.getZFLJG_FAT_W().toString());
        testWholeData.setZfljgXiajie(bodyfat.getZFLJG_XIAJIE() == null ? "" : bodyfat.getZFLJG_XIAJIE().toString());
        testWholeData.setZfljgShangjie(bodyfat.getZFLJG_SHANGJIE() == null ? "" : bodyfat.getZFLJG_SHANGJIE().toString());
        testWholeData.setJrjgShijizhi(bodyfat.getJRJG_SHIJIZHI() == null ? "" : bodyfat.getJRJG_SHIJIZHI().toString());
        testWholeData.setStzsfjgShijizhi(bodyfat.getSTZSFJG_SHIJIZHI() == null ? "" : bodyfat.getSTZSFJG_SHIJIZHI().toString());
        testWholeData.setDbzjgShijizhi(bodyfat.getDBZJG_SHIJIZHI() == null ? "" : bodyfat.getDBZJG_SHIJIZHI().toString());
        testWholeData.setWjyjgShijizhi(bodyfat.getWJYJG_SHIJIZHI() == null ? "" : bodyfat.getWJYJG_SHIJIZHI().toString());
        testWholeData.setYtbShicezhi(bodyfat.getYTB_SHICEZHI() == null ? "" : bodyfat.getYTB_SHICEZHI().toString());
        testWholeData.setYtbXiajie(bodyfat.getYTB_XIAJIE() == null ? "" : bodyfat.getYTB_XIAJIE().toString());
        testWholeData.setYtbShangjie(bodyfat.getYTB_SHANGJIE() == null ? "" : bodyfat.getYTB_SHANGJIE().toString());
        testWholeData.setFzxsShicezhi(bodyfat.getFZXS_SHICEZHI() == null ? "" : bodyfat.getFZXS_SHICEZHI().toString());
        testWholeData.setFzxsXiajie(bodyfat.getFZXS_XIAJIE() == null ? "" : bodyfat.getFZXS_XIAJIE().toString());
        testWholeData.setFzxsShangjie(bodyfat.getFZXS_SHANGJIE() == null ? "" : bodyfat.getFZXS_SHANGJIE().toString());
        testWholeData.setJhfxShangzhi(bodyfat.getJHFX_SHANGZHI() == null ? "" : bodyfat.getJHFX_SHANGZHI().toString());
        testWholeData.setJhfxXiazhi(bodyfat.getJHFX_XIAZHI() == null ? "" : bodyfat.getJHFX_XIAZHI().toString());
        testWholeData.setStllfxShangzhi(bodyfat.getSTLLFX_SHANGZHI() == null ? "" : bodyfat.getSTLLFX_SHANGZHI().toString());
        testWholeData.setStllfxXiazhi(bodyfat.getSTLLFX_XIAZHI() == null ? "" : bodyfat.getSTLLFX_XIAZHI().toString());
        testWholeData.setStllfxJirou(bodyfat.getSTLLFX_JIROU() == null ? "" : bodyfat.getSTLLFX_JIROU().toString());
        testWholeData.setShentinianling(bodyfat.getSHENTINIANLING() == null ? "" : bodyfat.getSHENTINIANLING().toString());
        testWholeData.setTizhongtiaojie(bodyfat.getTIZHONGTIAOJIE() == null ? "" : bodyfat.getTIZHONGTIAOJIE().toString());
        testWholeData.setZhifangtiaojie(bodyfat.getZHIFANGTIAOJIE() == null ? "" : bodyfat.getZHIFANGTIAOJIE().toString());
        testWholeData.setJiroutiaojie(bodyfat.getJIROUTIAOJIE() == null ? "" : bodyfat.getJIROUTIAOJIE().toString());
        testWholeData.setDxJichudaixie(bodyfat.getDX_JICHUDAIXIE() == null ? "" : bodyfat.getDX_JICHUDAIXIE().toString());
        testWholeData.setDxZongnengliangxiaohao(bodyfat.getDX_ZONGNENGLIANGXIAOHAO() == null ? "" : bodyfat.getDX_ZONGNENGLIANGXIAOHAO().toString());
        testWholeData.setFbzfShicezhi(bodyfat.getFBZF_SHICEZHI() == null ? "" : bodyfat.getFBZF_SHICEZHI().toString());
        testWholeData.setPostureone(bodyfat.getPosture_one());
        testWholeData.setPosturetwo(bodyfat.getPosture_two());
        testWholeData.setScore(bodyfat.getScore() == null ? "" : bodyfat.getScore().toString());
        testWholeData.setTzlspecifictime(StringUtils.trimToEmpty(bodyfat.getSpecificTime()));
        testWholeData.setTzltablegps(StringUtils.trimToEmpty(bodyfat.getGps()));
    }


    private static final List<BiConsumer<StringJoiner, MonitorDataDTO>> YOU_ER_FIELDS = Arrays.asList(
            (msg, dto) -> appendIfZero1(msg, dto.getShengao(), "身高"),
            (msg, dto) -> appendIfZero1(msg, dto.getZuogao(), "坐高"),
            (msg, dto) -> appendIfZero1(msg, dto.getTizhong(), "体重"),
            (msg, dto) -> appendIfZero1(msg, dto.getXiongwei(), "胸围"),
            (msg, dto) -> appendIfZero1(msg, dto.getTzl(), "体脂率"),
            (msg, dto) -> appendIfZero1(msg, dto.getAjxl(), "安静心率"),
            (msg, dto) -> appendIfZero1(msg, dto.getWoli(), "握力"),
            (msg, dto) -> appendIfZero1(msg, dto.getLdty(), "立定跳远"),
            (msg, dto) -> appendIfZero1(msg, dto.getZwtqq(), "坐位体前屈"),
            (msg, dto) -> appendIfZero1(msg, dto.getSjlxt(), "双脚连续跳"),
            (msg, dto) -> appendIfZero1(msg, dto.getZphm(), "走平衡木"),
            (msg, dto) -> appendIfZero1(msg, dto.getSwmrzap(), "15米绕障碍跑"),
            (msg, dto) -> appendSgzgIfZero1(msg, dto.getSgzg(), dto.getSgzgval()),
            (msg, dto) -> appendIfZero1(msg, dto.getShengaotizhong(), "身高与体重"),
            (msg, dto) -> appendIfZero1(msg, dto.getShengaozuogao(), "身高与坐高")
    );

    private static final List<BiConsumer<StringJoiner, MonitorDataDTO>> CHENG_REN_FIELDS = Arrays.asList(
            (msg, dto) -> appendIfZero1(msg, dto.getShengao(), "身高"),
            (msg, dto) -> appendIfZero1(msg, dto.getTizhong(), "体重"),
            (msg, dto) -> appendIfZero1(msg, dto.getYaowei(), "腰围"),
            (msg, dto) -> appendIfZero1(msg, dto.getTunwei(), "臀围"),
            (msg, dto) -> appendIfZero1(msg, dto.getTzl(), "体脂率"),
            (msg, dto) -> appendIfZero1(msg, dto.getFhl(), "肺活量"),
            (msg, dto) -> appendIfZero1(msg, dto.getGlc(), "功率车"),
            (msg, dto) -> appendIfZero1(msg, dto.getWoli(), "握力"),
            (msg, dto) -> appendIfZero1(msg, dto.getZongtiao(), "纵跳"),
            (msg, dto) -> appendIfZero1(msg, dto.getFwcgwc(), "俯卧撑/跪卧撑"),
            (msg, dto) -> appendIfZero1(msg, dto.getYfzywqz(), "1分钟仰卧起坐"),
            (msg, dto) -> appendIfZero1(msg, dto.getZwtqq(), "坐位体前屈"),
            (msg, dto) -> appendIfZero1(msg, dto.getBydjzl(), "闭眼单脚站立"),
            (msg, dto) -> appendIfZero1(msg, dto.getXzfys(), "选择反应时"),
            (msg, dto) -> appendIfZero1(msg, dto.getBeili(), "背力"),
            (msg, dto) -> appendIfZero1(msg, dto.getHeartrate(), "安静脉搏"),
            (msg, dto) -> appendIfZero1(msg, dto.getSystolicpressure(), "收缩压"),
            (msg, dto) -> appendIfZero1(msg, dto.getDiastolicpressure(), "舒张压"),
            (msg, dto) -> appendWithValue1(msg, dto.getYaoweitunwei(), dto.getYaoweitunweival(), "腰臀比"),
            (msg, dto) -> appendWithValue1(msg, dto.getMaiyacha(), dto.getMaiyachaval(), "脉压差"),
            (msg, dto) -> appendIfZero1(msg, dto.getShengaotizhong(), "身高与体重"),
            (msg, dto) -> appendIfZero1(msg, dto.getShengaofhl(), "身高与肺活量"),
            (msg, dto) -> appendIfZero1(msg, dto.getShengaowoli(), "身高与握力"),
            (msg, dto) -> appendIfZero1(msg, dto.getShengaobeili(), "身高与背力"),
            (msg, dto) -> appendIfZero1(msg, dto.getTizhongfhl(), "体重与肺活量"),
            (msg, dto) -> appendIfZero1(msg, dto.getTizhongwoli(), "体重与握力"),
            (msg, dto) -> appendIfZero1(msg, dto.getTizhongbeili(), "体重与背力"),
            (msg, dto) -> appendIfZero1(msg, dto.getYaoweishengaotizhong(), "腰围/身高与体重"),
            (msg, dto) -> appendIfZero1(msg, dto.getTunweishengaotizhong(), "臀围/身高与体重")
    );

    private static final List<BiConsumer<StringJoiner, MonitorDataDTO>> LAO_REN_FIELDS = Arrays.asList(
            (msg, dto) -> appendIfZero1(msg, dto.getShengao(), "身高"),
            (msg, dto) -> appendIfZero1(msg, dto.getTizhong(), "体重"),
            (msg, dto) -> appendIfZeroSafe1(msg, dto.getYaowei(), "腰围"),
            (msg, dto) -> appendIfZeroSafe1(msg, dto.getTunwei(), "臀围"),
            (msg, dto) -> appendIfZero1(msg, dto.getTzl(), "体脂率"),
            (msg, dto) -> appendIfZero1(msg, dto.getFhl(), "肺活量"),
            (msg, dto) -> appendIfZero1(msg, dto.getLfzydgtt(), "2分钟原地高抬腿"),
            (msg, dto) -> appendIfZero1(msg, dto.getWoli(), "握力"),
            (msg, dto) -> appendIfZero1(msg, dto.getZwtqq(), "坐位体前屈"),
            (msg, dto) -> appendIfZero1(msg, dto.getBydjzl(), "闭眼单脚站立"),
            (msg, dto) -> appendIfZero1(msg, dto.getXzfys(), "选择反应时"),
            (msg, dto) -> appendIfZero1(msg, dto.getSsmzz(), "30秒坐站"),
            (msg, dto) -> appendIfZero1(msg, dto.getHeartrate(), "安静脉搏"),
            (msg, dto) -> appendIfZero1(msg, dto.getSystolicpressure(), "收缩压"),
            (msg, dto) -> appendIfZero1(msg, dto.getDiastolicpressure(), "舒张压"),
            (msg, dto) -> appendWithValue1(msg, dto.getYaoweitunwei(), dto.getYaoweitunweival(), "腰臀比"),
            (msg, dto) -> appendWithValue1(msg, dto.getMaiyacha(), dto.getMaiyachaval(), "脉压差"),
            (msg, dto) -> appendIfZero1(msg, dto.getShengaotizhong(), "身高与体重"),
            (msg, dto) -> appendIfZero1(msg, dto.getShengaofhl(), "身高与肺活量"),
            (msg, dto) -> appendIfZero1(msg, dto.getShengaowoli(), "身高与握力"),
            (msg, dto) -> appendIfZero1(msg, dto.getTizhongfhl(), "体重与肺活量"),
            (msg, dto) -> appendIfZero1(msg, dto.getTizhongwoli(), "体重与握力"),
            (msg, dto) -> appendIfZeroSafe1(msg, dto.getYaoweishengaotizhong(), "腰围/身高与体重"),
            (msg, dto) -> appendIfZeroSafe1(msg, dto.getTunweishengaotizhong(), "臀围/身高与体重")
    );

    /**
     * 对整表数据按不同人群类型进行质量筛查，并批量更新筛查结果。
     *
     * @param testWholeDataTableName 数据表名称，用于查询和更新数据
     * @param peopleTypeList         人群类型列表，每个元素包含人群的名称和年龄范围等信息
     */
    public void processQualityScreening(String testWholeDataTableName,
                                        List<TPeopleType> peopleTypeList) {

        System.out.println("开始整表质量筛查: " + LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));

        // 并行处理所有人群类型，收集所有筛查结果
        List<MonitorDataDTO> allResults = peopleTypeList.parallelStream()
                .flatMap(peopleType -> {
                    List<MonitorDataDTO> dataList = processPeopleType(
                            testWholeDataTableName,
                            peopleType
                    );

                    if (!dataList.isEmpty()) {
                        System.out.printf("---[%s] 处理 %d 条数据---%n",
                                peopleType.getPeopletypename(), dataList.size());
                    }
                    return dataList.stream();
                })
                .collect(Collectors.toList());

        // 批量更新数据库
        if (!allResults.isEmpty()) {
            batchUpdateData(testWholeDataTableName, allResults);
            System.out.println("整表质量筛查完成: " + LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
        } else {
            log.info("未找到需要处理数据");
            System.out.println("未找到需要处理的数据");
        }
    }

    /**
     * 根据指定的人群类型从数据库中获取对应的数据并进行处理。
     *
     * @param tableName  数据表名
     * @param peopleType 人群类型对象，包含人群名称及年龄范围
     * @return 处理后的人群监测数据列表
     */
    private List<MonitorDataDTO> processPeopleType(String tableName, TPeopleType peopleType) {
        int typeName = peopleType.getId();
        List<MonitorDataDTO> dataList = Collections.emptyList();

        switch (typeName) {
            case 1:
                dataList = unionscreeningMapper.getQualityMonitorYouEr(
                        tableName,
                        peopleType.getPeopleagemin(),
                        peopleType.getPeopleagemax()
                );
                processData(dataList, YOU_ER_FIELDS);
                break;

            case 2:
                dataList = unionscreeningMapper.getQualityMonitorChengRen(
                        tableName,
                        peopleType.getPeopleagemin(),
                        peopleType.getPeopleagemax()
                );
                processData(dataList, CHENG_REN_FIELDS);
                break;

            case 3:
                dataList = unionscreeningMapper.getQualityMonitorLaoRen(
                        tableName,
                        peopleType.getPeopleagemin(),
                        peopleType.getPeopleagemax()
                );
                processData(dataList, LAO_REN_FIELDS);
                break;
        }

        return dataList;
    }

    /**
     * 对监测数据列表中的每条记录应用字段处理器，生成质量筛查结果。
     *
     * @param dataList        监测数据列表
     * @param fieldProcessors 字段处理函数列表，用于判断各字段是否符合要求
     */
    private void processData(List<MonitorDataDTO> dataList,
                             List<BiConsumer<StringJoiner, MonitorDataDTO>> fieldProcessors) {
        if (dataList == null || dataList.isEmpty()) return;

        // 并行处理数据集
        dataList.parallelStream().forEach(dto -> {
            StringJoiner message = new StringJoiner(",");

            // 应用所有字段处理器
            fieldProcessors.forEach(processor ->
                    processor.accept(message, dto)
            );

            if (message.length() > 0) {
                dto.setItemsispass(message.toString());
            }
        });
    }

    /**
     * 批量更新数据库中的筛查结果。
     *
     * @param tableName 数据表名
     * @param results   需要更新的监测数据列表
     */
    private void batchUpdateData(String tableName, List<MonitorDataDTO> results) {
        // 准备批量更新参数
        Map<String, Object> params = new ConcurrentHashMap<>();
        String idList = results.stream()
                .map(dto -> dto.getId().toString())
                .collect(Collectors.joining(","));

        params.put("tableName", tableName);
        params.put("idList", idList);
        params.put("ispassList", results);

        // 执行批量更新
        testWholeDataMapper.batchUpdate(params);
    }

    // 1. 定义辅助方法：提取内层数据并注入外层GPS
    private List<Map<String, Object>> extractInnerDataWithGPS(List<Map<String, Object>> outerList, String innerKey) {
        List<Map<String, Object>> result = new ArrayList<>();
        if (outerList == null) return result;

        for (Map<String, Object> outerMap : outerList) {
            // 获取外层GPS
            Object outerGPS = outerMap.get("gps");

            // 获取内层数据
            Object innerData = outerMap.get(innerKey);
            if (innerData instanceof List) {
                for (Object item : (List<?>) innerData) {
                    if (item instanceof Map) {
                        @SuppressWarnings("unchecked")
                        Map<String, Object> innerMap = (Map<String, Object>) item;

                        // 注入外层GPS到内层数据
                        if (outerGPS != null) {
                            innerMap.put("outerGPS", outerGPS); // 使用新字段保存外层GPS
                        }

                        // 保留内层所有原始字段
                        result.add(innerMap);
                    }
                }
            }
        }
        return result;
    }

    // 2. 定义辅助方法：获取测试年份
    private String extractTestYear(List<Map<String, Object>> outerList, String innerKey) {
        if (outerList == null || outerList.isEmpty()) return null;

        Map<String, Object> firstOuter = outerList.get(0);
        Object innerData = firstOuter.get(innerKey);
        if (innerData instanceof List) {
            List<?> innerList = (List<?>) innerData;
            if (!innerList.isEmpty() && innerList.get(0) instanceof Map) {
                @SuppressWarnings("unchecked")
                Map<String, Object> firstInner = (Map<String, Object>) innerList.get(0);
                Object testTime = firstInner.get("testTime");
                if (testTime != null) {
                    return testTime.toString().substring(0, 4);
                }
            }
        }
        return null;
    }

    // 3. 通用DTO转换方法（支持外层GPS注入）
    private <T> T convertMapToDto(Map<String, Object> map, Class<T> clazz) {
        try {
            // 使用FastJSON转换
            String jsonString = JSON.toJSONString(map);
            T dto = JSON.parseObject(jsonString, clazz);

            // 如果DTO有setOuterGPS方法，设置外层GPS
            try {
                Method setOuterGPS = clazz.getMethod("setOuterGPS", String.class);
                Object outerGPS = map.get("outerGPS");
                if (outerGPS != null) {
                    setOuterGPS.invoke(dto, outerGPS.toString());
                }
            } catch (NoSuchMethodException e) {
                // 没有该方法则忽略
            }

            return dto;
        } catch (Exception e) {
            log.error("DTO转换失败", e);
            return null;
        }
    }

    // 4. 通用分组方法
    private <T> Map<String, List<T>> groupByIdcard(
            List<Map<String, Object>> innerMaps,
            Class<T> clazz,
            String isCheckRetest) {

        if (innerMaps == null || innerMaps.isEmpty()) {
            return new HashMap<>();
        }

        return innerMaps.stream()
                .map(map -> convertMapToDto(map, clazz))
                .filter(Objects::nonNull)
                .filter(dto -> {
                    // 复测检查：使用外层GPS
                    if ("1".equals(isCheckRetest)) {
                        try {
                            // 优先使用outerGPS，没有则使用gps
                            Method getOuterGPS = clazz.getMethod("getOuterGPS");
                            String outerGPS = (String) getOuterGPS.invoke(dto);

                            if (outerGPS != null) {
                                return !"999.99,999.99".equals(outerGPS);
                            } else {
                                // 没有outerGPS则使用内层gps
                                Method getGps = clazz.getMethod("getGps");
                                String gps = (String) getGps.invoke(dto);
                                return gps != null && !"999.99,999.99".equals(gps);
                            }
                        } catch (Exception e) {
                            // 没有GPS相关方法则保留
                            return true;
                        }
                    }
                    return true;
                })
                .filter(dto -> {
                    try {
                        Method getIdcard = clazz.getMethod("getIdcard");
                        String idcard = (String) getIdcard.invoke(dto);
                        return idcard != null && !idcard.trim().isEmpty();
                    } catch (Exception e) {
                        return false;
                    }
                })
                .collect(Collectors.groupingBy(
                        dto -> {
                            try {
                                Method getIdcard = clazz.getMethod("getIdcard");
                                String idcard = (String) getIdcard.invoke(dto);
                                return idcard != null ? idcard.trim().toLowerCase() : "";
                            } catch (Exception e) {
                                return "";
                            }
                        },
                        HashMap::new,
                        Collectors.toList()
                ));
    }

    // 5. 处理国民体质数据（特殊逻辑）
    private Map<String, List<TestCorporeityDTO>> processGuomintizhi(
            String isCheckRetest,
            List<Map<String, Object>> testCorporeityResults) {

        // 提取内层数据并注入外层GPS
        List<Map<String, Object>> innerData = extractInnerDataWithGPS(
                testCorporeityResults, "TestCorporeityResults");

        return groupByIdcard(innerData, TestCorporeityDTO.class, isCheckRetest);
    }

    // 统一处理多个记录的数据类型（如国民体质）
    private static <T> void processTestData(Map<String, CombinedTestData> combinedDataMap,
                                            List<T> dataList,
                                            Consumer<T> processor) {
        if (dataList == null || dataList.isEmpty()) return;

        for (T dto : dataList) {
            processor.accept(dto);
        }
    }

    // 统一处理单个记录的数据类型（如血压计、体脂等）
    private static <T> void processSingleTestData(Map<String, CombinedTestData> combinedDataMap,
                                                  List<T> dataList,
                                                  Function<CombinedTestData, T> getter,
                                                  BiConsumer<CombinedTestData, T> setter) {
        if (dataList == null || dataList.isEmpty()) return;

        for (T dto : dataList) {
            try {
                // 获取testTime
                String time = getTestTime(dto);
                if (time == null) continue;

                CombinedTestData combined = combinedDataMap.computeIfAbsent(time, CombinedTestData::new);
                T existing = getter.apply(combined);

                // 选择最新记录
                if (existing == null) {
                    setter.accept(combined, dto);
                } else {
                    // 获取specificTime并比较
                    String newTime = getSpecificTime(dto);
                    String oldTime = getSpecificTime(existing);

                    if (newTime != null && (oldTime == null || newTime.compareTo(oldTime) > 0)) {
                        setter.accept(combined, dto);
                    }
                }
            } catch (Exception e) {
                // 错误处理
                System.err.println("Error processing data: " + e.getMessage());
            }
        }
    }

    // 辅助方法：获取testTime（根据不同类型）
    private static String getTestTime(Object dto) {
        if (dto instanceof TestTurgoscopeDTO) {
            return ((TestTurgoscopeDTO) dto).getTestTime();
        } else if (dto instanceof TestBodyfatDTO) {
            return ((TestBodyfatDTO) dto).getTestTime();
        } else if (dto instanceof TestPowerDTO) {
            return ((TestPowerDTO) dto).getTestTime();
        } else if (dto instanceof TestPowerHeartrateDTO) {
            return ((TestPowerHeartrateDTO) dto).getTesttime(); // 注意方法名不一致
        }
        return null;
    }

    // 辅助方法：获取specificTime（根据不同类型）
    private static String getSpecificTime(Object dto) {
        if (dto instanceof TestTurgoscopeDTO) {
            return ((TestTurgoscopeDTO) dto).getSpecifictime();
        } else if (dto instanceof TestBodyfatDTO) {
            return ((TestBodyfatDTO) dto).getSpecificTime();
        } else if (dto instanceof TestPowerDTO) {
            return ((TestPowerDTO) dto).getSpecifictime();
        } else if (dto instanceof TestPowerHeartrateDTO) {
            return ((TestPowerHeartrateDTO) dto).getSpecifictime();
        }
        return null;
    }

    // 封装成方法
    private Double getFirstValidTestAge(List<TestCorporeityDTO> corporeitys,
                                        TestTurgoscopeDTO turgoscope,
                                        TestBodyfatDTO bodyfat,
                                        TestPowerDTO power,
                                        TestPowerHeartrateDTO powerHeartrate) {
        // 检查单个对象（按优先级排序）
        if (bodyfat != null && bodyfat.getTestAge() != null) {
            return bodyfat.getTestAge();
        }
        if (power != null && power.getTestage() != null) {
            return power.getTestage();
        }
        if (turgoscope != null && turgoscope.getTestage() != null) {
            return turgoscope.getTestage();
        }
        if (powerHeartrate != null && powerHeartrate.getTestage() != null) {
            return powerHeartrate.getTestage();
        }

        // 检查列表
        if (corporeitys != null) {
            for (TestCorporeityDTO corp : corporeitys) {
                if (corp != null) {
                    Double age = corp.getTestAge();
                    if (age != null) {
                        return age;
                    }
                }
            }
        }

        return null; // 所有来源都无效
    }

    public TestWholeData getTestWholeData(MembersDataDTO membersData) {
        TestWholeData testWholeData = new TestWholeData();
        //设置测试状态是已完成
        testWholeData.setStatus(1);
        testWholeData.setRealname(membersData.getName());
        testWholeData.setSex(membersData.getGender());
        testWholeData.setBirthdate(membersData.getBirthTime());
        testWholeData.setAge(toSafeFloat(membersData.getAge()));
        testWholeData.setIdcard(membersData.getIdNumber());
        testWholeData.setNation(StringUtils.trimToEmpty(membersData.getEthnicity()));
        testWholeData.setAddress(StringUtils.trimToEmpty(membersData.getHomeAddress()));
        testWholeData.setWorkunit(StringUtils.trimToEmpty(membersData.getWorkUnit()));
        testWholeData.setCreatetime(StringUtils.trimToEmpty(membersData.getRegistrationDate()));
        testWholeData.setUpdatetime(StringUtils.trimToEmpty(membersData.getUpdatetime()));
        testWholeData.setDeleted(StringUtils.trimToEmpty(membersData.getDeleted()));
        testWholeData.setPosition(StringUtils.trimToEmpty(membersData.getPosition()));
        testWholeData.setOccupation(StringUtils.trimToEmpty(membersData.getOccupation()));
        testWholeData.setIndustry(StringUtils.trimToEmpty(membersData.getIndustry()));
        testWholeData.setTowncountry(StringUtils.trimToEmpty(membersData.getTownAndCountry()));
        testWholeData.setCulture(StringUtils.trimToEmpty(membersData.getLevelOfEducation()));
        testWholeData.setPhone(StringUtils.trimToEmpty(membersData.getPhoneNumber()));
        testWholeData.setMechanismname(StringUtils.trimToEmpty(membersData.getInstitutionName()));
        testWholeData.setMechanismcode(StringUtils.trimToEmpty(membersData.getInstitutionCode()));
        testWholeData.setInstrumentManufacturer(membersData.getInstrumentManufacturer());
        testWholeData.setTestage(toSafeFloat(membersData.getTestAge()));
        testWholeData.setTesttime(membersData.getTestDate());
        testWholeData.setTestmonth(truncateToMonthWithoutZeroPadFast(membersData.getTestDate()));
        testWholeData.setShengaoval(toSafeFloat(membersData.getHeight()));
        testWholeData.setShengaoscore(toSafeFloat(membersData.getHeightScore()));
        testWholeData.setShengaograde(StringUtils.trimToEmpty(membersData.getHeightAssessment()));
        testWholeData.setShengaotime(StringUtils.trimToEmpty(membersData.getDateOfHeightTest()));
        testWholeData.setShengaogps(StringUtils.trimToEmpty(membersData.getHeightGPS()));
        testWholeData.setZuogaoval(toSafeFloat(membersData.getSitUpHeight()));
        testWholeData.setZuogaoscore(toSafeFloat(membersData.getSitUpHeightScore()));
        testWholeData.setZuogaograde(StringUtils.trimToEmpty(membersData.getSitUpHeightAssessment()));
        testWholeData.setZuogaotime(StringUtils.trimToEmpty(membersData.getDateOfSitUpHeightTest()));
        testWholeData.setZuogaogps(StringUtils.trimToEmpty(membersData.getSitUpHeightGPS()));
        testWholeData.setTizhongval(toSafeFloat(membersData.getWeight()));
        testWholeData.setTizhongtime(StringUtils.trimToEmpty(membersData.getDateOfWeightTest()));
        testWholeData.setTizhonggps(StringUtils.trimToEmpty(membersData.getWeightGps()));
        testWholeData.setTzzsval(toSafeFloat(membersData.getBodyMassIndex()));
        testWholeData.setTzzsscore(toSafeFloat(membersData.getBmIScore()));
        testWholeData.setTzzsgrade(StringUtils.trimToEmpty(membersData.getBmiAssessment()));
        testWholeData.setTzzstime(StringUtils.trimToEmpty(membersData.getDateOfBMITest()));
        testWholeData.setTzzsgps(StringUtils.trimToEmpty(membersData.getBmiGPS()));
        testWholeData.setTzlval(toSafeFloat(membersData.getBodyFatRate()));
        testWholeData.setTzlscore(toSafeFloat(membersData.getBodyFatRateScore()));
        testWholeData.setTzlgrade(StringUtils.trimToEmpty(membersData.getBodyFatRateAssessment()));
        testWholeData.setTzltime(StringUtils.trimToEmpty(membersData.getDateOfBodyFatRateTest()));
        testWholeData.setTzlgps(StringUtils.trimToEmpty(membersData.getBodyFatRateGPS()));
        testWholeData.setXiongweival(toSafeFloat(membersData.getChestCircumference()));
        testWholeData.setXiongweiscore(toSafeFloat(membersData.getChestCircumferenceScore()));
        testWholeData.setXiongweigrade(StringUtils.trimToEmpty(membersData.getChestCircumferenceAssessment()));
        testWholeData.setXiongweitime(StringUtils.trimToEmpty(membersData.getDateOfChestCircumferenceTest()));
        testWholeData.setXiongweigps(StringUtils.trimToEmpty(membersData.getChestCircumferenceGPS()));
        testWholeData.setYaoweival(toSafeFloat(membersData.getWaist()));
        testWholeData.setYaoweitime(StringUtils.trimToEmpty(membersData.getDateOfWaistTest()));
        testWholeData.setYaoweigps(StringUtils.trimToEmpty(membersData.getWaistGPS()));
        testWholeData.setTunweival(toSafeFloat(membersData.getHip()));
        testWholeData.setTunweitime(StringUtils.trimToEmpty(membersData.getDateOfHipTest()));
        testWholeData.setTunweigps(StringUtils.trimToEmpty(membersData.getHipGPS()));
        testWholeData.setFhlval(toSafeFloat(membersData.getVitalCapacity()));
        testWholeData.setFhlscore(toSafeFloat(membersData.getVitalCapacityScore()));
        testWholeData.setFhlgrade(StringUtils.trimToEmpty(membersData.getVitalCapacityAssessment()));
        testWholeData.setFhltime(StringUtils.trimToEmpty(membersData.getDateOfVitalCapacityTest()));
        testWholeData.setFhlgps(StringUtils.trimToEmpty(membersData.getVitalCapacityGPS()));
        testWholeData.setGlcval(toSafeFloat(membersData.getRelativeValuesOfTheSecondLevelLoadTestOnAPowerBike()));
        testWholeData.setGlcscore(toSafeFloat(membersData.getSecondLevelLoadTestOnAPowerBikeScore()));
        testWholeData.setGlcgrade(StringUtils.trimToEmpty(membersData.getSecondLevelLoadTestOnAPowerBikeAssessment()));
        testWholeData.setGlctime(StringUtils.trimToEmpty(membersData.getDateOfSecondLevelLoadTestOnAPowerBike()));
        testWholeData.setGlcgps(StringUtils.trimToEmpty(membersData.getSecondLevelLoadTestOnAPowerBikeGPS()));
        testWholeData.setLfzydgttval(toSafeFloat(membersData.getMinute2LegRaisesInPlace()));
        testWholeData.setLfzydgttscore(toSafeFloat(membersData.getMinute2LegRaisesInPlaceScore()));
        testWholeData.setLfzydgttgrade(StringUtils.trimToEmpty(membersData.getMinute2LegRaisesInPlaceAssessment()));
        testWholeData.setLfzydgtttime(StringUtils.trimToEmpty(membersData.getEndOfMinute2LegRaisesInPlaceTest()));
        testWholeData.setLfzydgttgps(StringUtils.trimToEmpty(membersData.getMinute2LegRaisesInPlaceGPS()));
        testWholeData.setLfzydgttzval(toSafeFloat(membersData.getMinute2LegRaisesInPlaceLeftLeg()));
        testWholeData.setLfzydgttztime(StringUtils.trimToEmpty(membersData.getDateOfMinute2LegRaisesInPlaceLeftLeg()));
        testWholeData.setLfzydgttyval(toSafeFloat(membersData.getMinute2LegRaisesInPlaceRightLeg()));
        testWholeData.setLfzydgttytime(StringUtils.trimToEmpty(membersData.getDateOfMinute2LegRaisesInPlaceRightLegTest()));
        testWholeData.setAjxlval(toSafeFloat(membersData.getRestingHeartRate()));
        testWholeData.setAjxltime(StringUtils.trimToEmpty(membersData.getDateOfRestingHeartRate()));
        testWholeData.setAjxlgps(StringUtils.trimToEmpty(membersData.getRestingHeartRateGPS()));
        testWholeData.setWolival(toSafeFloat(membersData.getGripStrength()));
        testWholeData.setWoliscore(toSafeFloat(membersData.getGripStrengthScore()));
        testWholeData.setWoligrade(StringUtils.trimToEmpty(membersData.getGripStrengthAssessment()));
        testWholeData.setWolitime(StringUtils.trimToEmpty(membersData.getDateOfGripStrengthTest()));
        testWholeData.setWoligps(StringUtils.trimToEmpty(membersData.getGripStrengthGPS()));
        testWholeData.setZongtiaoval(toSafeFloat(membersData.getVerticalJump()));
        testWholeData.setZongtiaoscore(toSafeFloat(membersData.getVerticalJumpScore()));
        testWholeData.setZongtiaograde(StringUtils.trimToEmpty(membersData.getVerticalJumpAssessment()));
        testWholeData.setZongtiaotime(StringUtils.trimToEmpty(membersData.getDateOfVerticalJumpTest()));
        testWholeData.setZongtiaogps(StringUtils.trimToEmpty(membersData.getVerticalJumpGPS()));
        testWholeData.setFwcval(toSafeFloat(membersData.getPushUp()));
        testWholeData.setFwcscore(toSafeFloat(membersData.getPushUpScore()));
        testWholeData.setFwcgrade(StringUtils.trimToEmpty(membersData.getPushUpAssessment()));
        testWholeData.setFwctime(StringUtils.trimToEmpty(membersData.getDateOfPushUpTest()));
        testWholeData.setFwcgps(StringUtils.trimToEmpty(membersData.getPushUpGPS()));
        testWholeData.setGwcval(toSafeFloat(membersData.getKneelingPushUp()));
        testWholeData.setGwcscore(toSafeFloat(membersData.getKneelingPushUpScore()));
        testWholeData.setGwcgrade(StringUtils.trimToEmpty(membersData.getKneelingPushUpAssessment()));
        testWholeData.setGwctime(StringUtils.trimToEmpty(membersData.getDateOfKneelingPushUpTest()));
        testWholeData.setGwcgps(StringUtils.trimToEmpty(membersData.getKneelingPushUpGPS()));
        testWholeData.setYfzywqzval(toSafeFloat(membersData.getMinute1SitUps()));
        testWholeData.setYfzywqzscore(toSafeFloat(membersData.getMinute1SitUpsScore()));
        testWholeData.setYfzywqzgrade(StringUtils.trimToEmpty(membersData.getMinute1SitUpsAssessment()));
        testWholeData.setYfzywqztime(StringUtils.trimToEmpty(membersData.getDateOfMinute1SitUpsTest()));
        testWholeData.setYfzywqzgps(StringUtils.trimToEmpty(membersData.getMinute1SitUpsGPS()));
        testWholeData.setZwtqqval(toSafeFloat(membersData.getSeatedForwardBending()));
        testWholeData.setZwtqqscore(toSafeFloat(membersData.getSeatedForwardBendingScore()));
        testWholeData.setZwtqqgrade(StringUtils.trimToEmpty(membersData.getSeatedForwardBendingAssessment()));
        testWholeData.setZwtqqtime(StringUtils.trimToEmpty(membersData.getDateOfSeatedForwardBendingTest()));
        testWholeData.setZwtqqgps(StringUtils.trimToEmpty(membersData.getSeatedForwardBendingGPS()));
        testWholeData.setBydjzlval(toSafeFloat(membersData.getEyesClosedOneLeggedStand()));
        testWholeData.setBydjzlscore(toSafeFloat(membersData.getEyesClosedOneLeggedStandScore()));
        testWholeData.setBydjzlgrade(StringUtils.trimToEmpty(membersData.getEyesClosedOneLeggedStandAssessment()));
        testWholeData.setBydjzltime(StringUtils.trimToEmpty(membersData.getDateOfEyesClosedOnLeggedStandTest()));
        testWholeData.setBydjzlgps(StringUtils.trimToEmpty(membersData.getEyesClosedOneLeggedStandGPS()));
        testWholeData.setXzfysval(toSafeFloat(membersData.getSelectionReactionTime()));
        testWholeData.setXzfysscore(toSafeFloat(membersData.getSelectionReactionTimeScore()));
        testWholeData.setXzfysgrade(StringUtils.trimToEmpty(membersData.getSelectionReactionTimeAssessment()));
        testWholeData.setXzfystime(StringUtils.trimToEmpty(membersData.getDateOfSelectionReactionTimeTest()));
        testWholeData.setXzfysgps(StringUtils.trimToEmpty(membersData.getSelectionReactionTimeGPS()));
        testWholeData.setBeilival(toSafeFloat(membersData.getBackStrength()));
        testWholeData.setBeilitime(StringUtils.trimToEmpty(membersData.getDateOfBackStrengthTest()));
        testWholeData.setBeiligps(StringUtils.trimToEmpty(membersData.getBackStrengthGPS()));
        testWholeData.setSsmzzval(toSafeFloat(membersData.getSeconds30SittingAndStanding()));
        testWholeData.setSsmzzscore(toSafeFloat(membersData.getSeconds30SittingAndStandingScore()));
        testWholeData.setSsmzzgrade(StringUtils.trimToEmpty(membersData.getSeconds30SittingAndStandingAssessment()));
        testWholeData.setSsmzztime(StringUtils.trimToEmpty(membersData.getDateOfSeconds30SittingAndStandingTest()));
        testWholeData.setSsmzzgps(StringUtils.trimToEmpty(membersData.getSeconds30SittingAndStandingGPS()));
        testWholeData.setLdtyval(toSafeFloat(membersData.getStandingLongJump()));
        testWholeData.setLdtyscore(toSafeFloat(membersData.getStandingLongJumpScore()));
        testWholeData.setLdtygrade(StringUtils.trimToEmpty(membersData.getStandingLongJumpAssessment()));
        testWholeData.setLdtytime(StringUtils.trimToEmpty(membersData.getDateOfStandingLongJumpTest()));
        testWholeData.setLdtygps(StringUtils.trimToEmpty(membersData.getStandingLongJumpGPS()));
        testWholeData.setSjlxtval(toSafeFloat(membersData.getContinuousJumpsOnBothFeet()));
        testWholeData.setSjlxtscore(toSafeFloat(membersData.getContinuousJumpsOnBothFeetScore()));
        testWholeData.setSjlxtgrade(StringUtils.trimToEmpty(membersData.getContinuousJumpsOnBothFeetAssessment()));
        testWholeData.setSjlxttime(StringUtils.trimToEmpty(membersData.getDateOfContinuousJumpsOnBothFeetTest()));
        testWholeData.setSjlxtgps(StringUtils.trimToEmpty(membersData.getContinuousJumpsOnBothFeetGPS()));
        testWholeData.setSwmrzapval(toSafeFloat(membersData.getMeter15RunAroundObstacles()));
        testWholeData.setSwmrzapscore(toSafeFloat(membersData.getMeter15RunAroundObstaclesScore()));
        testWholeData.setSwmrzapgrade(StringUtils.trimToEmpty(membersData.getMeter15RunAroundObstaclesAssessment()));
        testWholeData.setSwmrzaptime(StringUtils.trimToEmpty(membersData.getDateOfMeter15RunAroundObstaclesTest()));
        testWholeData.setSwmrzapgps(StringUtils.trimToEmpty(membersData.getMeter15RunAroundObstaclesGPS()));
        testWholeData.setZphmval(toSafeFloat(membersData.getWalkingOnABalanceBeam()));
        testWholeData.setZphmscore(toSafeFloat(membersData.getWalkingSidewaysOnABalanceBeamScore()));
        testWholeData.setZphmgrade(StringUtils.trimToEmpty(membersData.getWalkingSidewaysOnABalanceBeamAssessment()));
        testWholeData.setZphmtime(StringUtils.trimToEmpty(membersData.getDateOfWalkingSidewaysOnABalanceBeamTest()));
        testWholeData.setZphmgps(StringUtils.trimToEmpty(membersData.getWalkingSidewaysOnABalanceBeamGPS()));
        testWholeData.setZphmnb(membersData.getWalkingSidewaysOnABalanceBeam() == null ? "" : membersData.getWalkingSidewaysOnABalanceBeam().toString());
        if (membersData.getNationalPhysicalFitnessCompositeScore() == null) {
            //该会员没有综合得分，表明该会员参与评价的指标未测试完，测试状态是未完成
            testWholeData.setStatus(0);
        } else {
            //综合得分不为空，表明参与评价的指标测试完成
            testWholeData.setZonghescore(toSafeFloat(membersData.getNationalPhysicalFitnessCompositeScore()));
            testWholeData.setZonghegrade(membersData.getNationalPhysicalFitnessCompositeAssessment());
        }
        testWholeData.setGps(StringUtils.trimToEmpty(membersData.getGps()));
        testWholeData.setMetval(toSafeFloat(membersData.getMetValue()));
        testWholeData.setRelativeval(toSafeFloat(membersData.getRelativeValuesOfTheSecondLevelLoadTestOnAPowerBike()));
        testWholeData.setAbsoluteval(toSafeFloat(membersData.getAbsoluteValuesOfTheSecondLevelLoadTestOnAPowerBike()));
        String glcHeartRate = joinDoubles(",", membersData.getQuietHeartRate(),
                membersData.getEndOfWarmUpPeriodHeartRate(),
                membersData.getHeartRateAfter60Seconds(),
                membersData.getHeartRateAfter90Seconds(),
                membersData.getHeartRateAfter120Seconds(),
                membersData.getHeartRateAfter150Seconds(),
                membersData.getHeartRateAfter180Seconds(),
                membersData.getEndOfTheFirstLevelLoadHeartRate(),
                membersData.getHeartRateAfter240Seconds(),
                membersData.getHeartRateAfter270Seconds(),
                membersData.getHeartRateAfter300Seconds(),
                membersData.getHeartRateAfter330Seconds(),
                membersData.getHeartRateAfter360Seconds(),
                membersData.getEndOfTheSecondLevelLoadHeartRate(),
                membersData.getEndOfRecoveryPeriodHeartRate());
        testWholeData.setGlcHeartRate(glcHeartRate);
        testWholeData.setGlcspecifictime(StringUtils.trimToEmpty(membersData.getDateOfSecondLevelLoadTestOnAPowerBike()));
        testWholeData.setGlctablegps(StringUtils.trimToEmpty(membersData.getSecondLevelLoadTestOnAPowerBikeGPS()));
        if (membersData.getRestingBloodPressureRestingPulse() == null) {
            //该会员没有心率，表明该会员没有测试血压计，判断是否是幼儿，如果不是幼儿，则该会员测试未完成
            if (isAgeAboveThreshold(membersData.getTestAge(), 20.0f)) {
                testWholeData.setStatus(0);
            }
        } else {
            //心率不为空，表明该会员测试了血压计
            testWholeData.setHeartrate(membersData.getRestingBloodPressureRestingPulse());
            testWholeData.setDiastolicpressure(membersData.getRestingBloodPressureDiastolic());
            testWholeData.setSystolicpressure(membersData.getRestingBloodPressureSystolic());
            testWholeData.setXyjspecifictime(StringUtils.trimToEmpty(membersData.getDateOfRestingBloodPressureTest()));
            testWholeData.setXyjgps(StringUtils.trimToEmpty(membersData.getRestingBloodPressureGPS()));
        }
        testWholeData.setShengao(membersData.getHeight() == null ? "" : membersData.getHeight().toString());
        testWholeData.setTizhong(membersData.getWeight() == null ? "" : membersData.getWeight().toString());
        testWholeData.setK1Zongzukang(membersData.getTotalImpedanceAt1kHz() == null ? "" : membersData.getTotalImpedanceAt1kHz().toString());
        testWholeData.setK5Zongzukang(membersData.getTotalImpedanceAt5kHz() == null ? "" : membersData.getTotalImpedanceAt5kHz().toString());
        testWholeData.setK20Zongzukang(membersData.getTotalImpedanceAt20kHz() == null ? "" : membersData.getTotalImpedanceAt20kHz().toString());
        testWholeData.setK50Zongzukang(membersData.getTotalImpedanceAt50kHz() == null ? "" : membersData.getTotalImpedanceAt50kHz().toString());
        testWholeData.setK50Xiangweicha(membersData.getK50_XIANGWEICHA() == null ? "" : membersData.getK50_XIANGWEICHA().toString());
        testWholeData.setK50Zuoshangzhizukang(membersData.getLeftUpperLimbImpedance() == null ? "" : membersData.getLeftUpperLimbImpedance().toString());
        testWholeData.setK50Youshangzhizukang(membersData.getRightUpperLimbImpedance() == null ? "" : membersData.getRightUpperLimbImpedance().toString());
        testWholeData.setK50Quganzukang(membersData.getTrunkImpedance() == null ? "" : membersData.getTrunkImpedance().toString());
        testWholeData.setK50Zuoxiazhizukang(membersData.getLeftLowerLimbImpedance() == null ? "" : membersData.getLeftLowerLimbImpedance().toString());
        testWholeData.setK50Youxiazhizukang(membersData.getRightUpperLimbImpedance() == null ? "" : membersData.getRightUpperLimbImpedance().toString());
        testWholeData.setK100Zongzukang(membersData.getTotalImpedanceAt100kHz() == null ? "" : membersData.getTotalImpedanceAt100kHz().toString());
        testWholeData.setK250Zongzukang(membersData.getTotalImpedanceAt250kHz() == null ? "" : membersData.getTotalImpedanceAt250kHz().toString());
        testWholeData.setK500Zongzukang(membersData.getTotalImpedanceAt500kHz() == null ? "" : membersData.getTotalImpedanceAt500kHz().toString());
        testWholeData.setK1000Zongzukang(membersData.getTotalImpedanceAt1000kHz() == null ? "" : membersData.getTotalImpedanceAt1000kHz().toString());
        testWholeData.setBztzBiaozhunzhi(membersData.getBZTZ_BIAOZHUNZHI() == null ? "" : membersData.getBZTZ_BIAOZHUNZHI().toString());
        testWholeData.setBztzXiajie(membersData.getBZTZ_XIAJIE() == null ? "" : membersData.getBZTZ_XIAJIE().toString());
        testWholeData.setBztzShangjie(membersData.getBZTZ_SHANGJIE() == null ? "" : membersData.getBZTZ_SHANGJIE().toString());
        testWholeData.setQztzShicezhi(membersData.getMeasuredLeanBodyMass() == null ? "" : membersData.getMeasuredLeanBodyMass().toString());
        testWholeData.setQztzXiajie(membersData.getQZTZ_XIAJIE() == null ? "" : membersData.getQZTZ_XIAJIE().toString());
        testWholeData.setQztzShangjie(membersData.getQZTZ_SHANGJIE() == null ? "" : membersData.getQZTZ_SHANGJIE().toString());
        testWholeData.setTzflShicezhi(membersData.getMeasuredBodyFatMass() == null ? "" : membersData.getMeasuredBodyFatMass().toString());
        testWholeData.setTzflXiajie(membersData.getTZFL_XIAJIE() == null ? "" : membersData.getTZFL_XIAJIE().toString());
        testWholeData.setTzflShangjie(membersData.getTZFL_SHANGJIE() == null ? "" : membersData.getTZFL_SHANGJIE().toString());
        testWholeData.setStjrlShicezhi(membersData.getMeasuredTotalBodyWater() == null ? "" : membersData.getMeasuredTotalBodyWater().toString());
        testWholeData.setStjrlXiajie(membersData.getSTJRL_XIAJIE() == null ? "" : membersData.getSTJRL_XIAJIE().toString());
        testWholeData.setStjrlShangjie(membersData.getSTJRL_SHANGJIE() == null ? "" : membersData.getSTJRL_SHANGJIE().toString());
        testWholeData.setGgjrShicezhi(membersData.getMeasuredSkeletalMuscleMass() == null ? "" : membersData.getMeasuredSkeletalMuscleMass().toString());
        testWholeData.setGgjrXiajie(membersData.getGGJR_XIAJIE() == null ? "" : membersData.getGGJR_XIAJIE().toString());
        testWholeData.setGgjrShangjie(membersData.getGGJR_SHANGJIE() == null ? "" : membersData.getGGJR_SHANGJIE().toString());
        testWholeData.setStzsfShicezhi(membersData.getMeasuredTotalBodyWater() == null ? "" : membersData.getMeasuredTotalBodyWater().toString());
        testWholeData.setStzsfXiajie(membersData.getSTZSF_XIAJIE() == null ? "" : membersData.getSTZSF_XIAJIE().toString());
        testWholeData.setStzsfShangjie(membersData.getSTZSF_SHANGJIE() == null ? "" : membersData.getSTZSF_SHANGJIE().toString());
        testWholeData.setDbzShicezhi(membersData.getMeasuredProteinMass() == null ? "" : membersData.getMeasuredProteinMass().toString());
        testWholeData.setDbzXiajie(membersData.getDBZ_XIAJIE() == null ? "" : membersData.getDBZ_XIAJIE().toString());
        testWholeData.setDbzShangjie(membersData.getDBZ_SHANGJIE() == null ? "" : membersData.getDBZ_SHANGJIE().toString());
        testWholeData.setWjyShicezhi(membersData.getMeasuredMineralMass() == null ? "" : membersData.getMeasuredMineralMass().toString());
        testWholeData.setWjyXiajie(membersData.getWJY_XIAJIE() == null ? "" : membersData.getWJY_XIAJIE().toString());
        testWholeData.setWjyShangjie(membersData.getWJY_SHANGJIE() == null ? "" : membersData.getWJY_SHANGJIE().toString());
        testWholeData.setXbwyShicezhi(membersData.getMeasuredExtracellularFluid() == null ? "" : membersData.getMeasuredExtracellularFluid().toString());
        testWholeData.setXbwyXiajie(membersData.getXBWY_XIAJIE() == null ? "" : membersData.getXBWY_XIAJIE().toString());
        testWholeData.setXbwyShangjie(membersData.getXBWY_SHANGJIE() == null ? "" : membersData.getXBWY_SHANGJIE().toString());
        testWholeData.setXbnyShicezhi(membersData.getMeasuredIntracellularFluid() == null ? "" : membersData.getMeasuredIntracellularFluid().toString());
        testWholeData.setXbnyXiajie(membersData.getXBNY_XIAJIE() == null ? "" : membersData.getXBNY_XIAJIE().toString());
        testWholeData.setXbnyShangjie(membersData.getXBNY_SHANGJIE() == null ? "" : membersData.getXBNY_SHANGJIE().toString());
        testWholeData.setZszjrlShicezhi(membersData.getMeasuredLeftUpperLimbMuscleMass() == null ? "" : membersData.getMeasuredLeftUpperLimbMuscleMass().toString());
        testWholeData.setZszjrlXiajie(membersData.getZSZJRL_XIAJIE() == null ? "" : membersData.getZSZJRL_XIAJIE().toString());
        testWholeData.setZszjrlShangjie(membersData.getZSZJRL_SHANGJIE() == null ? "" : membersData.getZSZJRL_SHANGJIE().toString());
        testWholeData.setYszjrlShicezhi(membersData.getMeasuredRightUpperLimbMuscleMass() == null ? "" : membersData.getMeasuredRightUpperLimbMuscleMass().toString());
        testWholeData.setYszjrlXiajie(membersData.getYSZJRL_XIAJIE() == null ? "" : membersData.getYSZJRL_XIAJIE().toString());
        testWholeData.setYszjrlShangjie(membersData.getYSZJRL_SHANGJIE() == null ? "" : membersData.getYSZJRL_SHANGJIE().toString());
        testWholeData.setQgjrlShicezhi(membersData.getMeasuredTrunkMuscleMass() == null ? "" : membersData.getMeasuredTrunkMuscleMass().toString());
        testWholeData.setQgjrlXiajie(membersData.getQGJRL_XIAJIE() == null ? "" : membersData.getQGJRL_XIAJIE().toString());
        testWholeData.setQgjrlShangjie(membersData.getQGJRL_SHANGJIE() == null ? "" : membersData.getQGJRL_SHANGJIE().toString());
        testWholeData.setZxzjrlShicezhi(membersData.getMeasuredLeftLowerLimbMuscleMass() == null ? "" : membersData.getMeasuredLeftLowerLimbMuscleMass().toString());
        testWholeData.setZxzjrlXiajie(membersData.getZXZJRL_XIAJIE() == null ? "" : membersData.getZXZJRL_XIAJIE().toString());
        testWholeData.setZxzjrlShangjie(membersData.getZXZJRL_SHANGJIE() == null ? "" : membersData.getZXZJRL_SHANGJIE().toString());
        testWholeData.setYxzjrlShicezhi(membersData.getMeasuredRightLowerLimbMuscleMass() == null ? "" : membersData.getMeasuredRightLowerLimbMuscleMass().toString());
        testWholeData.setYxzjrlXiajie(membersData.getYXZJRL_XIAJIE() == null ? "" : membersData.getYXZJRL_XIAJIE().toString());
        testWholeData.setYxzjrlShangjie(membersData.getYXZJRL_SHANGJIE() == null ? "" : membersData.getYXZJRL_SHANGJIE().toString());
        testWholeData.setZszzflShicezhi(membersData.getMeasuredLeftUpperLimbFatMass() == null ? "" : membersData.getMeasuredLeftUpperLimbFatMass().toString());
        testWholeData.setZszzflXiajie(membersData.getZSZZFL_XIAJIE() == null ? "" : membersData.getZSZZFL_XIAJIE().toString());
        testWholeData.setZszzflShangjie(membersData.getZSZZFL_SHANGJIE() == null ? "" : membersData.getZSZZFL_SHANGJIE().toString());
        testWholeData.setYszzflShicezhi(membersData.getMeasuredRightUpperLimbFatMass() == null ? "" : membersData.getMeasuredRightUpperLimbFatMass().toString());
        testWholeData.setYszzflXiajie(membersData.getYSZZFL_XIAJIE() == null ? "" : membersData.getYSZZFL_XIAJIE().toString());
        testWholeData.setYszzflShangjie(membersData.getYSZZFL_SHANGJIE() == null ? "" : membersData.getYSZZFL_SHANGJIE().toString());
        testWholeData.setQgzflShicezhi(membersData.getMeasuredTrunkFatMass() == null ? "" : membersData.getMeasuredTrunkFatMass().toString());
        testWholeData.setQgzflXiajie(membersData.getQGZFL_XIAJIE() == null ? "" : membersData.getQGZFL_XIAJIE().toString());
        testWholeData.setQgzflShangjie(membersData.getQGZFL_SHANGJIE() == null ? "" : membersData.getQGZFL_SHANGJIE().toString());
        testWholeData.setZxzzflShicezhi(membersData.getMeasuredLeftLowerLimbFatMass() == null ? "" : membersData.getMeasuredLeftLowerLimbFatMass().toString());
        testWholeData.setZxzzflXiajie(membersData.getZXZZFL_XIAJIE() == null ? "" : membersData.getZXZZFL_XIAJIE().toString());
        testWholeData.setZxzzflShangjie(membersData.getZXZZFL_SHANGJIE() == null ? "" : membersData.getZXZZFL_SHANGJIE().toString());
        testWholeData.setYxzzflShicezhi(membersData.getMeasuredRightLowerLimbFatMass() == null ? "" : membersData.getMeasuredRightLowerLimbFatMass().toString());
        testWholeData.setYxzzflXiajie(membersData.getYXZZFL_XIAJIE() == null ? "" : membersData.getYXZZFL_XIAJIE().toString());
        testWholeData.setYxzzflShangjie(membersData.getYXZZFL_SHANGJIE() == null ? "" : membersData.getYXZZFL_SHANGJIE().toString());
        testWholeData.setNzzfShicezhi(membersData.getMeasuredVisceralFatMass() == null ? "" : membersData.getMeasuredVisceralFatMass().toString());
        testWholeData.setTzjgShijizhi(membersData.getTZJG_SHIJIZHI() == null ? "" : membersData.getTZJG_SHIJIZHI().toString());
        testWholeData.setTzjgXiajie(membersData.getTZJG_XIAJIE() == null ? "" : membersData.getTZJG_XIAJIE().toString());
        testWholeData.setTzjgShangjie(membersData.getTZJG_SHANGJIE() == null ? "" : membersData.getTZJG_SHANGJIE().toString());
        testWholeData.setBmiShicezhi(membersData.getMeasuredBMI() == null ? "" : membersData.getMeasuredBMI().toString());
        testWholeData.setBmiXiajie(membersData.getBMI_XIAJIE() == null ? "" : membersData.getBMI_XIAJIE().toString());
        testWholeData.setBmiShangjie(membersData.getBMI_SHANGJIE() == null ? "" : membersData.getBMI_SHANGJIE().toString());
        testWholeData.setZfljgFatW(membersData.getMeasuredBodyFatPercentage() == null ? "" : membersData.getMeasuredBodyFatPercentage().toString());
        testWholeData.setZfljgXiajie(membersData.getZFLJG_XIAJIE() == null ? "" : membersData.getZFLJG_XIAJIE().toString());
        testWholeData.setZfljgShangjie(membersData.getZFLJG_SHANGJIE() == null ? "" : membersData.getZFLJG_SHANGJIE().toString());
        testWholeData.setJrjgShijizhi(membersData.getJRJG_SHIJIZHI() == null ? "" : membersData.getJRJG_SHIJIZHI().toString());
        testWholeData.setStzsfjgShijizhi(membersData.getSTZSFJG_SHIJIZHI() == null ? "" : membersData.getSTZSFJG_SHIJIZHI().toString());
        testWholeData.setDbzjgShijizhi(membersData.getDBZJG_SHIJIZHI() == null ? "" : membersData.getDBZJG_SHIJIZHI().toString());
        testWholeData.setWjyjgShijizhi(membersData.getWJYJG_SHIJIZHI() == null ? "" : membersData.getWJYJG_SHIJIZHI().toString());
        testWholeData.setYtbShicezhi(membersData.getYTB_SHICEZHI() == null ? "" : membersData.getYTB_SHICEZHI().toString());
        testWholeData.setYtbXiajie(membersData.getYTB_XIAJIE() == null ? "" : membersData.getYTB_XIAJIE().toString());
        testWholeData.setYtbShangjie(membersData.getYTB_SHANGJIE() == null ? "" : membersData.getYTB_SHANGJIE().toString());
        testWholeData.setFzxsShicezhi(membersData.getMeasuredEdemaCoefficient() == null ? "" : membersData.getMeasuredEdemaCoefficient().toString());
        testWholeData.setFzxsXiajie(membersData.getFZXS_XIAJIE() == null ? "" : membersData.getFZXS_XIAJIE().toString());
        testWholeData.setFzxsShangjie(membersData.getFZXS_SHANGJIE() == null ? "" : membersData.getFZXS_SHANGJIE().toString());
        testWholeData.setJhfxShangzhi(membersData.getJHFX_SHANGZHI() == null ? "" : membersData.getJHFX_SHANGZHI().toString());
        testWholeData.setJhfxXiazhi(membersData.getJHFX_XIAZHI() == null ? "" : membersData.getJHFX_XIAZHI().toString());
        testWholeData.setStllfxShangzhi(membersData.getSTLLFX_SHANGZHI() == null ? "" : membersData.getSTLLFX_SHANGZHI().toString());
        testWholeData.setStllfxXiazhi(membersData.getSTLLFX_XIAZHI() == null ? "" : membersData.getSTLLFX_XIAZHI().toString());
        testWholeData.setStllfxJirou(membersData.getSTLLFX_JIROU() == null ? "" : membersData.getSTLLFX_JIROU().toString());
        testWholeData.setShentinianling(membersData.getSHENTINIANLING() == null ? "" : membersData.getSHENTINIANLING().toString());
        testWholeData.setTizhongtiaojie(membersData.getTIZHONGTIAOJIE() == null ? "" : membersData.getTIZHONGTIAOJIE().toString());
        testWholeData.setZhifangtiaojie(membersData.getZHIFANGTIAOJIE() == null ? "" : membersData.getZHIFANGTIAOJIE().toString());
        testWholeData.setJiroutiaojie(membersData.getJIROUTIAOJIE() == null ? "" : membersData.getJIROUTIAOJIE().toString());
        testWholeData.setDxJichudaixie(membersData.getDX_JICHUDAIXIE() == null ? "" : membersData.getDX_JICHUDAIXIE().toString());
        testWholeData.setDxZongnengliangxiaohao(membersData.getDX_ZONGNENGLIANGXIAOHAO() == null ? "" : membersData.getDX_ZONGNENGLIANGXIAOHAO().toString());
        testWholeData.setFbzfShicezhi(membersData.getFBZF_SHICEZHI() == null ? "" : membersData.getFBZF_SHICEZHI().toString());
        testWholeData.setPostureone(membersData.getPosture_one());
        testWholeData.setPosturetwo(membersData.getPosture_two());
        testWholeData.setScore(membersData.getBodyFatRateScore() != null ? StringUtils.trimToEmpty(membersData.getBodyFatRateScore().toString()) : "");
        testWholeData.setTzlspecifictime(StringUtils.trimToEmpty(membersData.getDateOfBodyFatRateTest()));
        testWholeData.setTzltablegps(StringUtils.trimToEmpty(membersData.getBodyFatRateGPS()));
        //是否国测
        testWholeData.setType(1);
        //该会员完成测试进行质量筛查，未完成不进行质量筛查
        return testWholeData;
    }

    public TestWholeDataRetest getTestWholeDataRetest(MembersDataEntityDTO membersData) {
        TestWholeDataRetest testWholeDataRetest = new TestWholeDataRetest();
        testWholeDataRetest.setSex(membersData.getSex());
        testWholeDataRetest.setIdcard(membersData.getIdcard());
        testWholeDataRetest.setTowncountry(StringUtils.trimToEmpty(membersData.getTownAndCountry()));
        testWholeDataRetest.setMechanismcode(StringUtils.trimToEmpty(membersData.getMechanismCode()));
        testWholeDataRetest.setTestage(toSafeFloat(membersData.getTestAge()));
        testWholeDataRetest.setTesttime(membersData.getTestTime());
        testWholeDataRetest.setTestmonth(truncateToMonthWithoutZeroPadFast(membersData.getTestTime()));
        testWholeDataRetest.setShengaoval(toSafeFloat(membersData.getShengao()));
        testWholeDataRetest.setShengaoscore(toSafeFloat(membersData.getShengaoScore()));
        testWholeDataRetest.setShengaograde(StringUtils.trimToEmpty(membersData.getShengaoGrade()));
        testWholeDataRetest.setShengaotime(StringUtils.trimToEmpty(membersData.getShengaoTime()));
        testWholeDataRetest.setZuogaoval(toSafeFloat(membersData.getZuogao()));
        testWholeDataRetest.setZuogaoscore(toSafeFloat(membersData.getZuogaoScore()));
        testWholeDataRetest.setZuogaograde(StringUtils.trimToEmpty(membersData.getZuogaoGrade()));
        testWholeDataRetest.setZuogaotime(StringUtils.trimToEmpty(membersData.getZuogaoTime()));
        testWholeDataRetest.setTizhongval(toSafeFloat(membersData.getTizhong()));
        testWholeDataRetest.setTizhongtime(StringUtils.trimToEmpty(membersData.getTizhongTime()));
        testWholeDataRetest.setTzzsval(toSafeFloat(membersData.getTzzs()));
        testWholeDataRetest.setTzzsscore(toSafeFloat(membersData.getTzzsScore()));
        testWholeDataRetest.setTzzsgrade(StringUtils.trimToEmpty(membersData.getTzzsGrade()));
        testWholeDataRetest.setTzzstime(StringUtils.trimToEmpty(membersData.getTzzsTime()));
        testWholeDataRetest.setTzlval(toSafeFloat(membersData.getTzl()));
        testWholeDataRetest.setTzlscore(toSafeFloat(membersData.getTzlScore()));
        testWholeDataRetest.setTzlgrade(StringUtils.trimToEmpty(membersData.getTzlGrade()));
        testWholeDataRetest.setTzltime(StringUtils.trimToEmpty(membersData.getTzlTime()));
        testWholeDataRetest.setXiongweival(toSafeFloat(membersData.getXiongwei()));
        testWholeDataRetest.setXiongweiscore(toSafeFloat(membersData.getXiongweiScore()));
        testWholeDataRetest.setXiongweigrade(StringUtils.trimToEmpty(membersData.getXiongweiGrade()));
        testWholeDataRetest.setXiongweitime(StringUtils.trimToEmpty(membersData.getXiongweiTime()));
        testWholeDataRetest.setYaoweival(toSafeFloat(membersData.getYaowei()));
        testWholeDataRetest.setYaoweiscore(toSafeFloat(membersData.getYaoweiScore()));
        testWholeDataRetest.setYaoweigrade(StringUtils.trimToEmpty(membersData.getYaoweiGrade()));
        testWholeDataRetest.setYaoweitime(StringUtils.trimToEmpty(membersData.getYaoweiTime()));
        testWholeDataRetest.setTunweival(toSafeFloat(membersData.getTunwei()));
        testWholeDataRetest.setTunweiscore(toSafeFloat(membersData.getTunweiScore()));
        testWholeDataRetest.setTunweigrade(StringUtils.trimToEmpty(membersData.getTunweiGrade()));
        testWholeDataRetest.setTunweitime(StringUtils.trimToEmpty(membersData.getTunweiTime()));
        testWholeDataRetest.setFhlval(toSafeFloat(membersData.getFhl()));
        testWholeDataRetest.setFhlscore(toSafeFloat(membersData.getFhlScore()));
        testWholeDataRetest.setFhlgrade(StringUtils.trimToEmpty(membersData.getFhlGrade()));
        testWholeDataRetest.setFhltime(StringUtils.trimToEmpty(membersData.getFhlTime()));
        testWholeDataRetest.setGlcval(toSafeFloat(membersData.getGlc()));
        testWholeDataRetest.setGlcscore(toSafeFloat(membersData.getGlcScore()));
        testWholeDataRetest.setGlcgrade(StringUtils.trimToEmpty(membersData.getGlcGrade()));
        testWholeDataRetest.setGlctime(StringUtils.trimToEmpty(membersData.getGlcTime()));
        testWholeDataRetest.setLfzydgttval(toSafeFloat(membersData.getLfzydgtt()));
        testWholeDataRetest.setLfzydgttscore(toSafeFloat(membersData.getLfzydgttScore()));
        testWholeDataRetest.setLfzydgttgrade(StringUtils.trimToEmpty(membersData.getLfzydgttGrade()));
        testWholeDataRetest.setLfzydgtttime(StringUtils.trimToEmpty(membersData.getLfzydgttTime()));
        testWholeDataRetest.setLfzydgttzval(toSafeFloat(membersData.getLfzydgttz()));
        testWholeDataRetest.setLfzydgttztime(StringUtils.trimToEmpty(membersData.getLfzydgttzTime()));
        testWholeDataRetest.setLfzydgttyval(toSafeFloat(membersData.getLfzydgtty()));
        testWholeDataRetest.setLfzydgttytime(StringUtils.trimToEmpty(membersData.getLfzydgttyTime()));
        testWholeDataRetest.setAjxlval(toSafeFloat(membersData.getAjxl()));
        testWholeDataRetest.setAjxlscore(toSafeFloat(membersData.getAjxlScore()));
        testWholeDataRetest.setAjxlgrade(StringUtils.trimToEmpty(membersData.getAjxlGrade()));
        testWholeDataRetest.setAjxltime(StringUtils.trimToEmpty(membersData.getAjxlTime()));
        testWholeDataRetest.setWolival(toSafeFloat(membersData.getWoli()));
        testWholeDataRetest.setWoliscore(toSafeFloat(membersData.getWoliScore()));
        testWholeDataRetest.setWoligrade(StringUtils.trimToEmpty(membersData.getWoliGrade()));
        testWholeDataRetest.setWolitime(StringUtils.trimToEmpty(membersData.getWoliTime()));
        testWholeDataRetest.setZongtiaoval(toSafeFloat(membersData.getZongtiao()));
        testWholeDataRetest.setZongtiaoscore(toSafeFloat(membersData.getZongtiaoScore()));
        testWholeDataRetest.setZongtiaograde(StringUtils.trimToEmpty(membersData.getZongtiaoGrade()));
        testWholeDataRetest.setZongtiaotime(StringUtils.trimToEmpty(membersData.getZongtiaoTime()));
        testWholeDataRetest.setFwcval(toSafeFloat(membersData.getFwc()));
        testWholeDataRetest.setFwcscore(toSafeFloat(membersData.getFwcScore()));
        testWholeDataRetest.setFwcgrade(StringUtils.trimToEmpty(membersData.getFwcGrade()));
        testWholeDataRetest.setFwctime(StringUtils.trimToEmpty(membersData.getFwcTime()));
        testWholeDataRetest.setGwcval(toSafeFloat(membersData.getGwc()));
        testWholeDataRetest.setGwcscore(toSafeFloat(membersData.getGwcScore()));
        testWholeDataRetest.setGwcgrade(StringUtils.trimToEmpty(membersData.getGwcGrade()));
        testWholeDataRetest.setGwctime(StringUtils.trimToEmpty(membersData.getGwcTime()));
        testWholeDataRetest.setYfzywqzval(toSafeFloat(membersData.getYfzywqz()));
        testWholeDataRetest.setYfzywqzscore(toSafeFloat(membersData.getYfzywqzScore()));
        testWholeDataRetest.setYfzywqzgrade(StringUtils.trimToEmpty(membersData.getYfzywqzGrade()));
        testWholeDataRetest.setYfzywqztime(StringUtils.trimToEmpty(membersData.getYfzywqzTime()));
        testWholeDataRetest.setZwtqqval(toSafeFloat(membersData.getZwtqq()));
        testWholeDataRetest.setZwtqqscore(toSafeFloat(membersData.getZwtqqScore()));
        testWholeDataRetest.setZwtqqgrade(StringUtils.trimToEmpty(membersData.getZwtqqGrade()));
        testWholeDataRetest.setZwtqqtime(StringUtils.trimToEmpty(membersData.getZwtqqTime()));
        testWholeDataRetest.setBydjzlval(toSafeFloat(membersData.getBydjzl()));
        testWholeDataRetest.setBydjzlscore(toSafeFloat(membersData.getBydjzlScore()));
        testWholeDataRetest.setBydjzlgrade(StringUtils.trimToEmpty(membersData.getBydjzlGrade()));
        testWholeDataRetest.setBydjzltime(StringUtils.trimToEmpty(membersData.getBydjzlTime()));
        testWholeDataRetest.setXzfysval(toSafeFloat(membersData.getXzfys()));
        testWholeDataRetest.setXzfysscore(toSafeFloat(membersData.getXzfysScore()));
        testWholeDataRetest.setXzfysgrade(StringUtils.trimToEmpty(membersData.getXzfysGrade()));
        testWholeDataRetest.setXzfystime(StringUtils.trimToEmpty(membersData.getXzfysTime()));
        testWholeDataRetest.setBeilival(toSafeFloat(membersData.getBeli()));
        testWholeDataRetest.setBeiliscore(toSafeFloat(membersData.getBeliScore()));
        testWholeDataRetest.setBeiligrade(StringUtils.trimToEmpty(membersData.getBeliGrade()));
        testWholeDataRetest.setBeilitime(StringUtils.trimToEmpty(membersData.getBeliTime()));
        testWholeDataRetest.setSsmzzval(toSafeFloat(membersData.getSsmzz()));
        testWholeDataRetest.setSsmzzscore(toSafeFloat(membersData.getSsmzzScore()));
        testWholeDataRetest.setSsmzzgrade(StringUtils.trimToEmpty(membersData.getSsmzzGrade()));
        testWholeDataRetest.setSsmzztime(StringUtils.trimToEmpty(membersData.getSsmzzTime()));
        testWholeDataRetest.setLdtyval(toSafeFloat(membersData.getLdty()));
        testWholeDataRetest.setLdtyscore(toSafeFloat(membersData.getLdtyScore()));
        testWholeDataRetest.setLdtygrade(StringUtils.trimToEmpty(membersData.getLdtyGrade()));
        testWholeDataRetest.setLdtytime(StringUtils.trimToEmpty(membersData.getLdtyTime()));
        testWholeDataRetest.setSjlxtval(toSafeFloat(membersData.getSjlxt()));
        testWholeDataRetest.setSjlxtscore(toSafeFloat(membersData.getSjlxtScore()));
        testWholeDataRetest.setSjlxtgrade(StringUtils.trimToEmpty(membersData.getSjlxtGrade()));
        testWholeDataRetest.setSjlxttime(StringUtils.trimToEmpty(membersData.getSjlxtTime()));
        testWholeDataRetest.setSwmrzapval(toSafeFloat(membersData.getSwmrzap()));
        testWholeDataRetest.setSwmrzapscore(toSafeFloat(membersData.getSwmrzapScore()));
        testWholeDataRetest.setSwmrzapgrade(StringUtils.trimToEmpty(membersData.getSwmrzapGrade()));
        testWholeDataRetest.setSwmrzaptime(StringUtils.trimToEmpty(membersData.getSwmrzapTime()));
        testWholeDataRetest.setZphmval(toSafeFloat(membersData.getZphm()));
        testWholeDataRetest.setZphmscore(toSafeFloat(membersData.getZphmScore()));
        testWholeDataRetest.setZphmgrade(StringUtils.trimToEmpty(membersData.getZphmGrade()));
        testWholeDataRetest.setZphmtime(StringUtils.trimToEmpty(membersData.getZphmTime()));
        testWholeDataRetest.setZphmnb(membersData.getZphmnb() == null ? "" : membersData.getZphmnb().toString());
        if (StringUtils.isNotEmpty(membersData.getZongheScore().toString())) {
            //综合得分不为空，表明参与评价的指标测试完成
            testWholeDataRetest.setZonghescore(toSafeFloat(membersData.getZongheScore()));
            testWholeDataRetest.setZonghegrade(membersData.getZongheGrade());
        }
        testWholeDataRetest.setGps(StringUtils.trimToEmpty(membersData.getGps()));
        //是否复测通过;默认复测通过，后期根据需要调整
        testWholeDataRetest.setIspassretest(1);
        //是否国测
        testWholeDataRetest.setType(1);
        return testWholeDataRetest;
    }

    public TestWholeDataRetest getTestWholeDataRetest11(TestCorporeityResultsRetestDTO membersData) {
        TestWholeDataRetest testWholeDataRetest = new TestWholeDataRetest();
        testWholeDataRetest.setSex(membersData.getGender());
        testWholeDataRetest.setIdcard(membersData.getIdNumber());
        testWholeDataRetest.setTowncountry(StringUtils.trimToEmpty(membersData.getTownAndCountry()));
        testWholeDataRetest.setMechanismcode(StringUtils.trimToEmpty(membersData.getInstitutionCode()));
        testWholeDataRetest.setTestage(toSafeFloat(membersData.getTestAge()));
        testWholeDataRetest.setTesttime(membersData.getTestDate());
        testWholeDataRetest.setTestmonth(truncateToMonthWithoutZeroPadFast(membersData.getTestDate()));
        testWholeDataRetest.setShengaoval(toSafeFloat(membersData.getHeight()));
        testWholeDataRetest.setShengaoscore(toSafeFloat(membersData.getHeightScore()));
        testWholeDataRetest.setShengaograde(StringUtils.trimToEmpty(membersData.getHeightAssessment()));
        testWholeDataRetest.setShengaotime(StringUtils.trimToEmpty(membersData.getDateOfHeightTest()));
        testWholeDataRetest.setZuogaoval(toSafeFloat(membersData.getSitUpHeight()));
        testWholeDataRetest.setZuogaoscore(toSafeFloat(membersData.getSitUpHeightScore()));
        testWholeDataRetest.setZuogaograde(StringUtils.trimToEmpty(membersData.getSitUpHeightAssessment()));
        testWholeDataRetest.setZuogaotime(StringUtils.trimToEmpty(membersData.getDateOfSitUpHeightTest()));
        testWholeDataRetest.setTizhongval(toSafeFloat(membersData.getWeight()));
        testWholeDataRetest.setTizhongtime(StringUtils.trimToEmpty(membersData.getDateOfWeightTest()));
        testWholeDataRetest.setTzzsval(toSafeFloat(membersData.getBodyMassIndex()));
        testWholeDataRetest.setTzzsscore(toSafeFloat(membersData.getBmIScore()));
        testWholeDataRetest.setTzzsgrade(StringUtils.trimToEmpty(membersData.getBmiAssessment()));
        testWholeDataRetest.setTzzstime(StringUtils.trimToEmpty(membersData.getDateOfBMITest()));
        testWholeDataRetest.setTzlval(toSafeFloat(membersData.getBodyFatRate()));
        testWholeDataRetest.setTzlscore(toSafeFloat(membersData.getBodyFatRateScore()));
        testWholeDataRetest.setTzlgrade(StringUtils.trimToEmpty(membersData.getBodyFatRateAssessment()));
        testWholeDataRetest.setTzltime(StringUtils.trimToEmpty(membersData.getDateOfBodyFatRateTest()));
        testWholeDataRetest.setXiongweival(toSafeFloat(membersData.getChestCircumference()));
        testWholeDataRetest.setXiongweiscore(toSafeFloat(membersData.getChestCircumferenceScore()));
        testWholeDataRetest.setXiongweigrade(StringUtils.trimToEmpty(membersData.getChestCircumferenceAssessment()));
        testWholeDataRetest.setXiongweitime(StringUtils.trimToEmpty(membersData.getDateOfChestCircumferenceTest()));
        testWholeDataRetest.setYaoweival(toSafeFloat(membersData.getWaist()));
        testWholeDataRetest.setYaoweitime(StringUtils.trimToEmpty(membersData.getDateOfWaistTest()));
        testWholeDataRetest.setTunweival(toSafeFloat(membersData.getHip()));
        testWholeDataRetest.setTunweitime(StringUtils.trimToEmpty(membersData.getDateOfHipTest()));
        testWholeDataRetest.setFhlval(toSafeFloat(membersData.getVitalCapacity()));
        testWholeDataRetest.setFhlscore(toSafeFloat(membersData.getVitalCapacityScore()));
        testWholeDataRetest.setFhlgrade(StringUtils.trimToEmpty(membersData.getVitalCapacityAssessment()));
        testWholeDataRetest.setFhltime(StringUtils.trimToEmpty(membersData.getDateOfVitalCapacityTest()));
        testWholeDataRetest.setGlcval(toSafeFloat(membersData.getRelativeValuesOfTheSecondLevelLoadTestOnAPowerBike()));
        testWholeDataRetest.setGlcscore(toSafeFloat(membersData.getSecondLevelLoadTestOnAPowerBikeScore()));
        testWholeDataRetest.setGlcgrade(StringUtils.trimToEmpty(membersData.getSecondLevelLoadTestOnAPowerBikeAssessment()));
        testWholeDataRetest.setGlctime(StringUtils.trimToEmpty(membersData.getDateOfSecondLevelLoadTestOnAPowerBike()));
        testWholeDataRetest.setLfzydgttval(toSafeFloat(membersData.getMinute2LegRaisesInPlace()));
        testWholeDataRetest.setLfzydgttscore(toSafeFloat(membersData.getMinute2LegRaisesInPlaceScore()));
        testWholeDataRetest.setLfzydgttgrade(StringUtils.trimToEmpty(membersData.getMinute2LegRaisesInPlaceAssessment()));
        testWholeDataRetest.setLfzydgtttime(StringUtils.trimToEmpty(membersData.getEndOfMinute2LegRaisesInPlaceTest()));
        testWholeDataRetest.setLfzydgttzval(toSafeFloat(membersData.getMinute2LegRaisesInPlaceLeftLeg()));
        testWholeDataRetest.setLfzydgttztime(StringUtils.trimToEmpty(membersData.getDateOfMinute2LegRaisesInPlaceLeftLeg()));
        testWholeDataRetest.setLfzydgttyval(toSafeFloat(membersData.getMinute2LegRaisesInPlaceRightLeg()));
        testWholeDataRetest.setLfzydgttytime(StringUtils.trimToEmpty(membersData.getDateOfMinute2LegRaisesInPlaceRightLegTest()));
        testWholeDataRetest.setAjxlval(toSafeFloat(membersData.getRestingHeartRate()));
        testWholeDataRetest.setAjxltime(StringUtils.trimToEmpty(membersData.getDateOfRestingHeartRate()));
        testWholeDataRetest.setWolival(toSafeFloat(membersData.getGripStrength()));
        testWholeDataRetest.setWoliscore(toSafeFloat(membersData.getGripStrengthScore()));
        testWholeDataRetest.setWoligrade(StringUtils.trimToEmpty(membersData.getGripStrengthAssessment()));
        testWholeDataRetest.setWolitime(StringUtils.trimToEmpty(membersData.getDateOfGripStrengthTest()));
        testWholeDataRetest.setZongtiaoval(toSafeFloat(membersData.getVerticalJump()));
        testWholeDataRetest.setZongtiaoscore(toSafeFloat(membersData.getVerticalJumpScore()));
        testWholeDataRetest.setZongtiaograde(StringUtils.trimToEmpty(membersData.getVerticalJumpAssessment()));
        testWholeDataRetest.setZongtiaotime(StringUtils.trimToEmpty(membersData.getDateOfVerticalJumpTest()));
        testWholeDataRetest.setFwcval(toSafeFloat(membersData.getPushUp()));
        testWholeDataRetest.setFwcscore(toSafeFloat(membersData.getPushUpScore()));
        testWholeDataRetest.setFwcgrade(StringUtils.trimToEmpty(membersData.getPushUpAssessment()));
        testWholeDataRetest.setFwctime(StringUtils.trimToEmpty(membersData.getDateOfPushUpTest()));
        testWholeDataRetest.setGwcval(toSafeFloat(membersData.getKneelingPushUp()));
        testWholeDataRetest.setGwcscore(toSafeFloat(membersData.getKneelingPushUpScore()));
        testWholeDataRetest.setGwcgrade(StringUtils.trimToEmpty(membersData.getKneelingPushUpAssessment()));
        testWholeDataRetest.setGwctime(StringUtils.trimToEmpty(membersData.getDateOfKneelingPushUpTest()));
        testWholeDataRetest.setYfzywqzval(toSafeFloat(membersData.getMinute1SitUps()));
        testWholeDataRetest.setYfzywqzscore(toSafeFloat(membersData.getMinute1SitUpsScore()));
        testWholeDataRetest.setYfzywqzgrade(StringUtils.trimToEmpty(membersData.getMinute1SitUpsAssessment()));
        testWholeDataRetest.setYfzywqztime(StringUtils.trimToEmpty(membersData.getDateOfMinute1SitUpsTest()));
        testWholeDataRetest.setZwtqqval(toSafeFloat(membersData.getSeatedForwardBending()));
        testWholeDataRetest.setZwtqqscore(toSafeFloat(membersData.getSeatedForwardBendingScore()));
        testWholeDataRetest.setZwtqqgrade(StringUtils.trimToEmpty(membersData.getSeatedForwardBendingAssessment()));
        testWholeDataRetest.setZwtqqtime(StringUtils.trimToEmpty(membersData.getDateOfSeatedForwardBendingTest()));
        testWholeDataRetest.setBydjzlval(toSafeFloat(membersData.getEyesClosedOneLeggedStand()));
        testWholeDataRetest.setBydjzlscore(toSafeFloat(membersData.getEyesClosedOneLeggedStandScore()));
        testWholeDataRetest.setBydjzlgrade(StringUtils.trimToEmpty(membersData.getEyesClosedOneLeggedStandAssessment()));
        testWholeDataRetest.setBydjzltime(StringUtils.trimToEmpty(membersData.getDateOfEyesClosedOnLeggedStandTest()));
        testWholeDataRetest.setXzfysval(toSafeFloat(membersData.getSelectionReactionTime()));
        testWholeDataRetest.setXzfysscore(toSafeFloat(membersData.getSelectionReactionTimeScore()));
        testWholeDataRetest.setXzfysgrade(StringUtils.trimToEmpty(membersData.getSelectionReactionTimeAssessment()));
        testWholeDataRetest.setXzfystime(StringUtils.trimToEmpty(membersData.getDateOfSelectionReactionTimeTest()));
        testWholeDataRetest.setBeilival(toSafeFloat(membersData.getBackStrength()));
        testWholeDataRetest.setBeilitime(StringUtils.trimToEmpty(membersData.getDateOfBackStrengthTest()));
        testWholeDataRetest.setSsmzzval(toSafeFloat(membersData.getSeconds30SittingAndStanding()));
        testWholeDataRetest.setSsmzzscore(toSafeFloat(membersData.getSeconds30SittingAndStandingScore()));
        testWholeDataRetest.setSsmzzgrade(StringUtils.trimToEmpty(membersData.getSeconds30SittingAndStandingAssessment()));
        testWholeDataRetest.setSsmzztime(StringUtils.trimToEmpty(membersData.getDateOfSeconds30SittingAndStandingTest()));
        testWholeDataRetest.setLdtyval(toSafeFloat(membersData.getStandingLongJump()));
        testWholeDataRetest.setLdtyscore(toSafeFloat(membersData.getStandingLongJumpScore()));
        testWholeDataRetest.setLdtygrade(StringUtils.trimToEmpty(membersData.getStandingLongJumpAssessment()));
        testWholeDataRetest.setLdtytime(StringUtils.trimToEmpty(membersData.getDateOfStandingLongJumpTest()));
        testWholeDataRetest.setSjlxtval(toSafeFloat(membersData.getContinuousJumpsOnBothFeet()));
        testWholeDataRetest.setSjlxtscore(toSafeFloat(membersData.getContinuousJumpsOnBothFeetScore()));
        testWholeDataRetest.setSjlxtgrade(StringUtils.trimToEmpty(membersData.getContinuousJumpsOnBothFeetAssessment()));
        testWholeDataRetest.setSjlxttime(StringUtils.trimToEmpty(membersData.getDateOfContinuousJumpsOnBothFeetTest()));
        testWholeDataRetest.setSwmrzapval(toSafeFloat(membersData.getMeter15RunAroundObstacles()));
        testWholeDataRetest.setSwmrzapscore(toSafeFloat(membersData.getMeter15RunAroundObstaclesScore()));
        testWholeDataRetest.setSwmrzapgrade(StringUtils.trimToEmpty(membersData.getMeter15RunAroundObstaclesAssessment()));
        testWholeDataRetest.setSwmrzaptime(StringUtils.trimToEmpty(membersData.getDateOfMeter15RunAroundObstaclesTest()));
        testWholeDataRetest.setZphmval(toSafeFloat(membersData.getWalkingOnABalanceBeam()));
        testWholeDataRetest.setZphmscore(toSafeFloat(membersData.getWalkingSidewaysOnABalanceBeamScore()));
        testWholeDataRetest.setZphmgrade(StringUtils.trimToEmpty(membersData.getWalkingSidewaysOnABalanceBeamAssessment()));
        testWholeDataRetest.setZphmtime(StringUtils.trimToEmpty(membersData.getDateOfWalkingSidewaysOnABalanceBeamTest()));
        testWholeDataRetest.setZphmnb(membersData.getWalkingSidewaysOnABalanceBeam() == null ? "" : membersData.getWalkingSidewaysOnABalanceBeam().toString());
        if (membersData.getNationalPhysicalFitnessCompositeScore() != null) {
            //综合得分不为空，表明参与评价的指标测试完成
            testWholeDataRetest.setZonghescore(toSafeFloat(membersData.getNationalPhysicalFitnessCompositeScore()));
            testWholeDataRetest.setZonghegrade(membersData.getNationalPhysicalFitnessCompositeAssessment());
        }
        testWholeDataRetest.setGps(StringUtils.trimToEmpty(membersData.getGps()));
        //是否复测通过;默认复测通过，后期根据需要调整
        testWholeDataRetest.setIspassretest(1);
        //是否国测
        testWholeDataRetest.setType(1);
        return testWholeDataRetest;
    }

    public SysUserLoginDTO getAppSecret(String appKey) {
//        SysUserLogin user = new SysUserLogin();
//        user.setLoginName(appKey);
        //对数据库中密码解密
        return sysUserInfoMapper.getByLg(appKey);
    }

}
